
                             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 EkmConfig.    )absolute_import)division)unicode_literals)base)iam)iam_util)resource_argsc                   &    e Zd ZdZed        Zd Zy)SetIamPolicya  Set the IAM policy for an EkmConfig.

  Sets the IAM policy for the EkmConfig in a location 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 EkmConfig with location `us-central1`:

    $ {command} policy.json --location=us-central1
  c                 X    t        j                  | dd       | j                  dd       y )NTz
--locationpolicy_filez%JSON or YAML file with the IAM policy)help)r	   AddKmsLocationResourceArgForKMSadd_argument)parsers    ,lib/surface/kms/ekm_config/set_iam_policy.pyArgszSetIamPolicy.Args,   s/    11&$M
 .  0    c                 v   t        j                         }t        j                  |j                  |j
                        \  }}|j                  j                  j                         }dj                  |j                  |j                        }t        j                  |||      }t        j                  |d       |S )Nz$projects/{0}/locations/{1}/ekmConfig	EkmConfig)cloudkms_baseGetMessagesModuler   ParseYamlOrJsonPolicyFiler   PolicyCONCEPTSlocationParseformat
projectsIdlocationsIdr   SetEkmConfigIamPolicyLogSetIamPolicy)selfargsmessagespolicyupdate_masklocation_refekm_config_nameresults           r   RunzSetIamPolicy.Run3   s    ..0H"<<(//+FK ==))//1L<CC!9!9;O&&LF_k:Mr   N)__name__
__module____qualname____doc__staticmethodr   r+    r   r   r   r      s      0 0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   r1   r   r   <module>r8      s2    ( &  ' A / ( 3 8"4<< "r   