
                            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,                  \
R.                   " S S\
R0                  5      5       5       rg)z1Implementation of objects set-iam-policy command.    )absolute_import)division)unicode_literals)	cloud_api)metadata_field_converters)base)iam_util)errors_util)flags)iam_command_util)name_expansion)storage_url)set_iam_policy_taskc              #   J  #    U(       a  [         R                  R                  nO[         R                  R                  n[         R                  " U [
        R                  R                  UUS9 H0  n[        R                  " UR                  R                  U5      v   M2     g7f)z+Generates SetIamPolicyTask's for execution.)fields_scopeobject_staterecursion_requestedN)r   RecursionSettingYESNO_WITH_WARNINGNameExpansionIteratorr   FieldsScopeSHORTr   SetObjectIamPolicyTaskresourcer   )url_stringsrecurser   policyr   name_expansion_results         -lib/surface/storage/objects/set_iam_policy.py_set_iam_policy_task_iteratorr!   !   s     (99==(99II-CC((..-	  
4
4&&22F  s   B!B#c                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
SetIamPolicy3   z Set access policy for an object.z
      *{command}* behaves similarly to *{parent_command} set-object-acl*, but
      uses the IAM policy binding syntax.
      a/  
      To set the access policy for OBJECT on BUCKET to the policy defined in
      POLICY-FILE run:

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

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

        $ {command} -r gs://b* POLICY-FILE
      )DESCRIPTIONEXAMPLESc                     U R                  SSSS9  [        R                  " U 5        U R                  SSSS9  U R                  S	S
SS9  U R                  SSSSSS9  [        R                  " U 5        g )Nurls+z;The URLs for objects whose access policy is being replaced.)nargshelpz--all-versions
store_truezKUpdate the IAM policies of all versions of an object in a versioned bucket.)actionr+   z-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+   z-Rz-rz--recursivezjRecursively set the IAM policies of the contents of any directories that match the source path expression.)add_argumentr	   AddArgForPolicyFiler   add_continue_on_error_flag)parsers    r    ArgsSetIamPolicy.ArgsL   s    
J  L   (
  
 "  # >  ? 
$$V,    c           	      
   UR                    Hl  n[        R                  " U5      nUR                  (       d!  [        R
                  " UR                  U5        [        R                  " UR                  U5        Mn     [        R                  " UR                  UR                  S9n[        R                  " [        UR                   UR                  [        R                   " U5      U5      UR"                  5      u  pVXPl        U$ )N)custom_etag)r(   r   storage_url_from_string	recursiver
   raise_error_if_not_cloud_objectcommand_pathraise_error_if_not_gcsr   process_iam_filepolicy_fileetagr   execute_set_iam_task_iteratorr!   r   get_object_state_from_flagscontinue_on_error	exit_code)selfargs
url_stringurlr   rB   outputs          r    RunSetIamPolicy.Rung   s    ii
//
;c^^33D4E4EsK(():):C@	   '77dii1F(FF%IINN--d3		
 	I NMr4   )rB   N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr2   rH   __static_attributes__ r4   r    r#   r#   3   s1     )



-( - -4r4   r#   N)rN   
__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!   HiddenUniverseCompatibleCommandr#   rR   r4   r    <module>r]      sj    8 &  ' 4 M ( 3 : 4 ? = : H$ F4<< F  Fr4   