
    	                         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  G d dej                        Z
 G d	 d
ej                        Zy)zIAM completers.    )absolute_import)division)unicode_literals)
completers)	resourcesc                   0     e Zd ZdZd fd	Zd Zd Z xZS )IamRolesCompletera(  An IAM role completer for a resource argument.

  The Complete() method override bypasses the completion cache.

  Attributes:
    _resource_dest: The argparse Namespace dest string for the resource
      argument that has the roles.
    _resource_collection: The resource argument collection.
  c                 H    t        t        | 
  di | || _        || _        y )N )superr	   __init___resource_dest_resource_collection)selfresource_destresource_collectionkwargs	__class__s       0lib/googlecloudsdk/command_lib/iam/completers.pyr   zIamRolesCompleter.__init__%   s&    	
T+5f5'D 3D    c                     t         j                  j                  |j                  | j                        | j
                  |j                        }|j                         }dddddd|gS )N)
collectiondefault_resolverbetaiamzlist-grantable-rolesz--quietz--flatten=namez--format=disable)r   REGISTRYParseGetValuer   r   SelfLink)r   parameter_inforesource_refresource_uris       r   GetListCommandz IamRolesCompleter.GetListCommand*   sq    %%++ 3 34,,'00 , 2L  ((*LE190,@ @r   c                     | j                  |      }| j                  ||      }|xs g D cg c]  }||j                  |      r| c}S c c}w )z;Bypasses the cache and returns completions matching prefix.)r#   GetAllItems
startswith)r   prefixr    commanditemsitems         r   CompletezIamRolesCompleter.Complete3   s_    !!.1GWn5E"$ 7 	  s   A)NN)__name__
__module____qualname____doc__r   r#   r+   __classcell__r   s   @r   r	   r	      s    4
@r   r	   c                        e Zd Z fdZ xZS )IamServiceAccountCompleterc                 0    t        t        | 
  dddi| y )Nlist_commandzBiam service-accounts list --quiet --flatten=email --format=disabler   )r   r3   r   )r   r   r   s     r   r   z#IamServiceAccountCompleter.__init__?   s'    	
$d4 9 r   )r,   r-   r.   r   r0   r1   s   @r   r3   r3   =   s     r   r3   N)r/   
__future__r   r   r   googlecloudsdk.command_lib.utilr   googlecloudsdk.corer   ListCommandCompleterr	   r3   r   r   r   <module>r:      s>      &  ' 6 ) 
77  F!@!@ r   