
    	                     V   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 dd	lmZ e
j                   e
j                   e
j"                  j$                  e
j"                  j&                  e
j"                  j(                         G d
 de
j*                                      Zy)zSet IAM cluster policy command.    )absolute_import)division)unicode_literals)dataproc)iam_helpers)base)flags)iam_utilc                   &    e Zd ZdZed        Zd Zy)SetIamPolicya%  Set IAM policy for a cluster.

  Sets the IAM policy for a cluster, given a cluster name and the policy.

  ## EXAMPLES

  The following command sets the IAM policy for a cluster with the name
  `example-cluster-name-1` using policy.yaml:

    $ {command} example-cluster-name-1 policy.yaml
  c                     t        j                  | j                               }t        j                  |d|j
                         |j                  ddd       y )Nzset the policy onpolicy_filePOLICY_FILEzW        Path to a local JSON or YAML formatted file containing a valid policy.
        )metavarhelp)dpDataprocReleaseTrackr	   AddClusterResourceArgapi_versionadd_argument)clsparserr   s      /lib/surface/dataproc/clusters/set_iam_policy.pyArgszSetIamPolicy.Args.   sS    {{3++-.H	(; ( 4 46
      c                    t        j                  | j                               }|j                  }t	        j
                  |j                  |j                        }t        j                  |_
        |j                  |      }|j                  j                  j                         }|j                  |j!                         |      }|j"                  j$                  j'                  |      S )N)policy)resourcesetIamPolicyRequest)r   r   r   messagesr
   ParsePolicyFiler   Policyr   !MAX_LIBRARY_IAM_SUPPORTED_VERSIONversionSetIamPolicyRequestCONCEPTSclusterParse2DataprocProjectsRegionsClustersSetIamPolicyRequestRelativeNameclientprojects_regions_clustersr   )selfargsr   r!   r   set_iam_policy_requestcluster_refrequests           r   RunzSetIamPolicy.Run:   s    {{4,,./H  H%%d&6&6HF BBFN%999H--''--/KII))+2 J 4G ??44AA'JJr   N)__name__
__module____qualname____doc__classmethodr   r3    r   r   r   r      s!    

 	 	Kr   r   N)r7   
__future__r   r   r   googlecloudsdk.api_lib.dataprocr   r   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.dataprocr	   googlecloudsdk.command_lib.iamr
   UniverseCompatibleReleaseTracksr   ALPHABETAGACommandr   r9   r   r   <module>rE      s     & &  ' : 7 ( 5 3 T..33T5F5F5I5I&K4<< &K &Kr   