
                            S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  S	S
S.r\	R                  \	R                  " \	R                  R                   5       " S S\	R"                  5      5       5       r\\l        g)z'logging views set_iam_policy' command.

Set the IAM policy for a logging view resource.

This command replaces the existing IAM policy for an logging view resource,
given a file encoded in JSON or YAML that contains the IAM policy.
    )absolute_import)division)unicode_literals)util)arg_parsers)base)iam_utilz+
        Set an IAM policy for a view.
    z
        To set the IAM policy using a json file 'my_policy.json' for the view `my-view` in `my-bucket` in the `global` location, run:

        $ {command} my-view /path/to/my_policy.json --bucket=my-bucket --location=global
    )DESCRIPTIONEXAMPLESc                   .    \ rS rSrSr\S 5       rS rSrg)SetIamPolicy,   zSet IAM policy for a view.c                     U R                  SSS9  [        R                  " U S5        [        R                  " U SS5        U R                  SS[        R
                  " SS	5      S
S9  [        R                  " U 5        g)z Register flags for this command.VIEW_IDz!ID of the view to set IAM policy.)helpzview to set IAM policyTz.Location of the bucket that contains the view.z--bucketz.+zmust be non-emptyz(ID of the bucket that contains the view.)requiredtyper   N)add_argumentr   AddParentArgsAddBucketLocationArgr   RegexpValidatorr	   AddArgForPolicyFile)parsers    +lib/surface/logging/views/set_iam_policy.pyArgsSetIamPolicy.Args1   s~     	(KLv78F ((0CD7	     (    c                    [         R                  " [         R                  " [         R                  " U5      SUR                  5      SUR                  5      n[         R
                  " 5       n[        R                  " UR                  UR                  5      u  pE[         R                  " X$5      n[        R                  " US5        U$ )zThis is what gets called when the user runs this command.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    command invocation.

Returns:
  The IAM policy.
bucketsviewszlogging view)r   CreateResourceNameGetBucketLocationFromArgsbucketr   GetMessagesr	   ParseYamlOrJsonPolicyFilepolicy_filePolicyr   LogSetIamPolicy)selfargsviewmessagespolicy_resultss          r   RunSetIamPolicy.RunA   s     ""**40)T[[	
 	D !H22(//IF -GT>2Nr    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r0   __static_attributes__r2   r   r   r   r   ,   s     #) )r   r   N)r7   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r   googlecloudsdk.command_lib.iamr	   DETAILED_HELPUniverseCompatibleReleaseTracksReleaseTrackGACommandr   detailed_helpr2   r   r   <module>rE      s    '  ' / / ( 3		 D%%(()*4<< * * *Z + r   