
    }
                         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                   G d
 de
j                                Zy)z*Set IAM autoscaling policy 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)SetIamPolicya6  Set IAM policy for an autoscaling policy.

  Sets the IAM policy for an autoscaling policy, given an autoscaling policy ID
  and the IAM policy.

  ## EXAMPLES
    The following command will read an IAM policy defined in a JSON file
    'policy.json' and set it for an autoscaling-policy with identifier
    'example-autoscaling-policy'

        $ {command} autoscaling-policies set-iam-policy \
            example-autoscaling-policy policy.json

    See https://cloud.google.com/iam/docs/managing-policies for details of the
    policy file format and contents.
  c                     t        j                  | j                               }t        j                  |d|j
                         t        j                  |       y )Nzretrieve the IAM policy for)dpDataprocReleaseTrackr	   AddAutoscalingPolicyResourceArgapi_versionr
   AddArgForPolicyFile)clsparserr   s      ;lib/surface/dataproc/autoscaling_policies/set_iam_policy.pyArgszSetIamPolicy.Args/   sD    {{3++-.H	))&2O*2*>*>@  (    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
   ParsePolicyFilepolicy_filePolicyr   !MAX_LIBRARY_IAM_SUPPORTED_VERSIONversionSetIamPolicyRequestCONCEPTSautoscaling_policyParse=DataprocProjectsRegionsAutoscalingPoliciesSetIamPolicyRequestRelativeNameclient$projects_regions_autoscalingPoliciesr   )selfargsr   r   r   set_iam_policy_request
policy_refrequests           r   RunzSetIamPolicy.Run6   s    {{4,,./H  H%%d&6&6HF BBFN%999H11779JTT((*2 U 4G
 ????LL r   N)__name__
__module____qualname____doc__classmethodr   r0    r   r   r   r      s     " ) )r   r   N)r4   
__future__r   r   r   googlecloudsdk.api_lib.dataprocr   r   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.dataprocr	   googlecloudsdk.command_lib.iamr
   DefaultUniverseOnlyCommandr   r6   r   r   <module>r>      sG    1 &  ' : 7 ( 5 3 *4<< * *r   