
    0
                         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 dd
lmZ ddlmZ  G d dej"                        Zy)z>Command for listing testable permissions for a given resource.    )absolute_import)division)unicode_literals)
list_pager)
exceptions)util)base)flags)iam_util)	resourcesc                   &    e Zd ZdZed        Zd Zy)ListTestablePermissionsa&  List IAM testable permissions for a resource.

  Testable permissions mean the permissions that user can add or remove in
  a role at a given resource.
  The resource can be referenced either via the full resource name or via a URI.

  ## EXAMPLES

  List testable permissions for a resource identified via full resource name:

    $ {command} //cloudresourcemanager.googleapis.com/organizations/1234567

  List testable permissions for a resource identified via URI:

    $ {command} https://www.googleapis.com/compute/v1/projects/example-project
  c                     t        j                  d      j                  |        t        j                  j                  |        y )Nz get the testable permissions for)r
   GetResourceNameFlagAddToParserr	   FILTER_FLAG)parsers    ,lib/surface/iam/list_testable_permissions.pyArgszListTestablePermissions.Args2   s1    	*,,7K,?  (    c                    d }|j                   j                  d      r|j                   }nW|j                   j                  d      r<t        j                  t        j
                  j                  |j                               }|st        j                  d      t        j                         \  }}t        j                  |j                  |j                  |      ddd      S )	Nz//httpz<The given resource is not a valid full resource name or URL.)fullResourceNamepermissionsQueryTestablePermissionspageSize)fieldmethodbatch_size_attribute)resource
startswithr   GetFullResourceNamer   REGISTRYParser   InvalidResourceExceptionr   GetClientAndMessagesr   YieldFromListr   QueryTestablePermissionsRequest)selfargsr    clientmessagess        r   RunzListTestablePermissions.Run8   s    H}}%h		!	!&	)--



"
"4==
13h//
HJ J 002FH##00(0K)') )r   N)__name__
__module____qualname____doc__staticmethodr   r-    r   r   r   r       s     " ) )
)r   r   N)r1   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.iamr   r   googlecloudsdk.callioper	   googlecloudsdk.command_lib.iamr
   r   googlecloudsdk.corer   Commandr   r3   r   r   <module>r;      s9     E &  ' ' 1 + ( 0 3 )))dll ))r   