
                             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 ej                  ej                   G d
 dej                                      Zy)z1Implementation of objects get-iam-policy command.    )absolute_import)division)unicode_literals)api_factory)base)errors_util)iam_command_util)storage_urlc                   0    e Zd ZdZdddZed        Zd Zy)GetIamPolicyz$Get the access policy for an object.z
      *{command}* behaves similarly to *{parent_command} get-object-acl*, but
      uses the IAM policy binding syntax in the output.
      z
      To get the access policy for OBJECT in BUCKET:

        $ {command} gs://BUCKET/OBJECT

      To output the access policy for OBJECT in BUCKET to a file:

        $ {command} gs://BUCKET/OBJECT > policy.txt
      )DESCRIPTIONEXAMPLESc                 *    | j                  dd       y )Nurlz#Request IAM policy for this object.)help)add_argument)parsers    -lib/surface/storage/objects/get_iam_policy.pyArgszGetIamPolicy.Args3   s    
$IJ    c                    t        j                  |j                        }t        j                  |j
                  |       t        j                  |j
                  |       t        j                  |j                        }t        j                  |j                        j                  |j                  |j                  |j                        S )N)r
   storage_url_from_stringr   r   raise_error_if_not_cloud_objectcommand_pathraise_error_if_not_gcsr	   get_single_matching_urlr   get_apischemeget_object_iam_policybucket_nameresource_name
generation)selfargs
url_objectmatching_urls       r   RunzGetIamPolicy.Run7   s    44TXX>J//0A0A:N&&t'8'8*E#;;DHHEL|223II  ,"<"<! !r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r'    r   r   r   r      s3     -


-$ K K!r   r   N)r+   
__future__r   r   r   googlecloudsdk.api_lib.storager   googlecloudsdk.callioper   "googlecloudsdk.command_lib.storager   r	   r
   HiddenUniverseCompatibleCommandr   r.   r   r   <module>r6      sS    8 &  ' 6 ( : ? :  !4<<  !   !r   