
                             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  G d	 d
ej                        Zy)z!Set the IAM policy for a keyring.    )absolute_import)division)unicode_literals)base)iam)iam_util)flagsc                   &    e Zd ZdZed        Zd Zy)SetIamPolicya  Set the IAM policy for a keyring.

  Sets the IAM policy for the given keyring as defined in a JSON or YAML file.

  See https://cloud.google.com/iam/docs/managing-policies for details of
  the policy file format and contents.

  ## EXAMPLES
  The following command will read am IAM policy defined in a JSON file
  'policy.json' and set it for the keyring `fellowship` with location `global`:

    $ {command} fellowship policy.json --location=global
  c                     t        j                  | d       t        j                  | d       | j                  dd       y )Nkeyringzwhose IAM policy to updatepolicy_filez%JSON or YAML file with the IAM policy)help)r	   AddLocationFlagAddKeyRingArgumentadd_argument)parsers    *lib/surface/kms/keyrings/set_iam_policy.pyArgszSetIamPolicy.Args+   s<    	&),	V%AB
 .> @    c                 (   t        j                         }t        j                  |j                  |j
                        \  }}t        j                  |      }t        j                  |||      }t        j                  |j                         d       |S )Nr   )cloudkms_baseGetMessagesModuler   ParseYamlOrJsonPolicyFiler   Policyr	   ParseKeyRingNamer   SetKeyRingIamPolicyLogSetIamPolicyName)selfargsmessagespolicyupdate_maskkeyring_refresults          r   RunzSetIamPolicy.Run2   sy    ..0H"<<T=M=M=E__NFK ((.K$$[&+FF[--/;Mr   N)__name__
__module____qualname____doc__staticmethodr   r'    r   r   r   r      s"     @ @	r   r   N)r+   
__future__r   r   r   googlecloudsdk.api_lib.cloudkmsr   r   r   googlecloudsdk.calliopegooglecloudsdk.command_lib.iamr   googlecloudsdk.command_lib.kmsr	   Commandr   r-   r   r   <module>r4      s2    ( &  ' A / ( 3 04<< r   