
    G                         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	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 r\
R,                   " S S\
R.                  5      5       rg)z1Implementation of buckets set-iam-policy command.    )absolute_import)division)unicode_literals)	cloud_api)metadata_field_converters)base)iam_util)errors_util)flags)iam_command_util)storage_url)wildcard_iterator)set_iam_policy_taskc              #      #    U  HZ  n[         R                  " U[        R                  R                  S9 H&  n[
        R                  " UR                  U5      v   M(     M\     g7f)z+Generates SetIamPolicyTask's for execution.)fields_scopeN)r   get_wildcard_iteratorr   FieldsScopeSHORTr   SetBucketIamPolicyTaskr   )url_stringspolicy
url_stringresources       -lib/surface/storage/buckets/set_iam_policy.py_set_iam_policy_task_iteratorr   !   sS     j%;;!6!6!<!<>66


 >  s   A"A$c                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
SetIamPolicy+   z Set the IAM policy for a bucket.z
      Set the IAM policy for a bucket. For more information, see [Cloud
      Identity and Access
      Management](https://cloud.google.com/storage/docs/access-control/iam).
      z
      To set the IAM policy in POLICY-FILE on BUCKET:

        $ {command} gs://BUCKET POLICY-FILE

      To set the IAM policy in POLICY-FILE on all buckets beginning with "b":

        $ {command} gs://b* POLICY-FILE
      )DESCRIPTIONEXAMPLESc                     U R                  SSSS9  U R                  SSSS9  [        R                  " U 5        [        R                  " U 5        g )	Nurls+zCURLs for buckets to apply the IAM policy to. Can include wildcards.)nargshelpz-ez--etagzCustom etag to set on IAM policy. API will reject etags that do not match this value, making it useful as a precondition during concurrent operations.)r%   )add_argumentr	   AddArgForPolicyFiler   add_continue_on_error_flag)parsers    r   ArgsSetIamPolicy.ArgsB   s^    
"  #
 "  #   (	$$V,    c                 f   UR                    H:  n[        R                  " U5      n[        R                  " UR
                  U5        M<     [        R                  " UR                  UR                  S9n[        R                  " [        UR                   U5      UR                  5      u  pVXPl        U$ )N)custom_etag)r"   r   storage_url_from_stringr
   raise_error_if_not_gcs_bucketcommand_pathr   process_iam_filepolicy_fileetagr   execute_set_iam_task_iteratorr   continue_on_error	exit_code)selfargsr   urlr   r7   outputs          r   RunSetIamPolicy.RunR   s    ii
//
;c//0A0A3G   '77dii1F(FF%dii8 I NMr,   )r7   N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr*   r<   __static_attributes__ r,   r   r   r   +   s/    (

-& - -r,   r   N)rB   
__future__r   r   r   googlecloudsdk.api_lib.storager   'googlecloudsdk.api_lib.storage.gcs_jsonr   googlecloudsdk.callioper   googlecloudsdk.command_lib.iamr	   "googlecloudsdk.command_lib.storager
   r   r   r   r   (googlecloudsdk.command_lib.storage.tasksr   r   UniverseCompatibleCommandr   rF   r,   r   <module>rP      s[    8 &  ' 4 M ( 3 : 4 ? : @ H 24<< 2 2r,   