
    )	                     ,   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
 ddlmZ  ej                  ej                  j                  ej                  j                   ej                  j"                         G d	 d
ej$                               Zy)z'Command to set IAM policy for a folder.    )absolute_import)division)unicode_literals)folders)base)iam_util)flagsc                   &    e Zd ZdZed        Zd Zy)SetIamPolicyaW  Set IAM policy for a folder.

  Sets the IAM policy for a folder, given a folder ID and a file encoded in
  JSON or YAML that contains the IAM policy.

  ## EXAMPLES

  The following command reads an IAM policy defined in a JSON file `policy.json`
  and sets it for a folder with the ID `3589215982`:

    $ {command} 3589215982 policy.json
  c                 r    t        j                  d      j                  |        | j                  dd       y )Nzwhose policy you want to set.policy_filez&JSON or YAML file with the IAM policy.)help)r	   FolderIdArgAddToParseradd_argument)parsers    6lib/surface/resource_manager/folders/set_iam_policy.pyArgszSetIamPolicy.Args+   s6    	56BB6J
D  F    c                 X   t        j                         }t        j                  |j                  |j
                        \  }}t        j                  |_        d|vr|dz  }d|vr|dz  }t        j                  |j                  ||      }t        j                  |j                  d       |S )Nbindingsz	,bindingsetagz,etagfolder)r   FoldersMessagesr   ParsePolicyFileWithUpdateMaskr   Policy!MAX_LIBRARY_IAM_SUPPORTED_VERSIONversionr   idLogSetIamPolicy)selfargsmessagespolicyupdate_maskresults         r   RunzSetIamPolicy.Run1   s    &&(H"@@(//+FK??FN $[ k[ Wk!!$''6;?FTWWh/Mr   N)__name__
__module____qualname____doc__staticmethodr   r'    r   r   r   r      s"     F F
r   r   N)r+   
__future__r   r   r   'googlecloudsdk.api_lib.resource_managerr   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr   +googlecloudsdk.command_lib.resource_managerr	   ReleaseTracksReleaseTrackALPHABETAGACommandr   r-   r   r   <module>r9      sv    . &  ' ; ( 3 = D%%++T->->-C-C%%((*#4<< #*#r   