
                             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  G d	 d
ej                        Zy)z'Command to list the available accounts.    )absolute_import)division)unicode_literals)base)log)
properties)storec                   ,    e Zd ZdZed        Zd Zd Zy)Lista  Lists credentialed accounts.

  Lists accounts whose credentials have been obtained using `gcloud init`,
  `gcloud auth login` and `gcloud auth activate-service-account`, and shows
  which account is active. The active account is used by gcloud and other Google
  Cloud CLI tools to access Google Cloud Platform. While there is no limit on
  the number of accounts with stored credentials, there is only one active
  account.

  ## EXAMPLES

  To set an existing account to be the current active account, run:

    $ gcloud config set core/account your-email-account@gmail.com

  If you don't have an existing account, create one using:

    $ gcloud init

  To list the active account name:

    $ gcloud auth list --filter=status:ACTIVE --format="value(account)"

  To list the inactive account names with prefix `test`:

    $ gcloud auth list --filter="-status:ACTIVE account:test*" --format="value(account)"
  c                 h    t         j                  j                  |        | j                  dd       y )Nz--filter-accountz        List only credentials for one account. Use
        --filter="account~_PATTERN_" to select accounts that match
        _PATTERN_.)help)r   URI_FLAGRemoveFromParseradd_argument)parsers    lib/surface/auth/list.pyArgsz	List.Args;   s/    MM""6*
      c                 d   t        j                         }|j                  r(|D cg c]  }|j                  |j                  k(  r| }}d}|D ]A  }|j                  t
        j                  j                  j                  j                  k7  s?d} n |r/|j                         j                  t         j                         |S |D cg c],  }t        j                  |j                  |j                        . }}|j                         j                  t         j                         |S c c}w c c}w )a   Run the 'gcloud auth list' command to list the accounts.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation (i.e. group and command arguments combined).

    Returns:
      [googlecloudsdk.core.credentials.store.AcctInfo] or
        [googlecloudsdk.core.credentials.store.AcctInfoWithUniverseDomain]: A
        list of AcctInfo objects if all accounts are from googleapis.com,
        otherwise a list of AcctInfoWithUniverseDomain objects.
    FT)c_storeAllAccountsWithUniverseDomainsfilter_accountaccountuniverse_domainr   VALUEScoredefaultGetDisplayInfo	AddFormat)ACCOUNT_TABLE_WITH_UNIVERSE_DOMAIN_FORMATAcctInfostatusACCOUNT_TABLE_FORMAT)selfargsaccount_info_listaccount_infoshow_universe_domains        r   RunzList.RunE   s/     >>@ 0/l!!T%8%88 /   !)

&
&##33;;<  $ * 
%%

;
;  0/l 

<//1D1D
E/  
 %%g&B&BC?0s   "D(1D-c                     |r t         j                  j                  d       y t         j                  j                  d       y )NzK
To set the active account, run:
    $ gcloud config set account `ACCOUNT`
zK
No credentialed accounts.

To login, run:
  $ gcloud auth login `ACCOUNT`
)r   r"   Print)r$   resources_were_displayeds     r   EpilogzList.Epilogu   s5    	jj  
 
jj  r   N)__name__
__module____qualname____doc__staticmethodr   r)   r-    r   r   r   r      s&    :  .`r   r   N)r1   
__future__r   r   r   googlecloudsdk.callioper   googlecloudsdk.corer   r   googlecloudsdk.core.credentialsr	   r   ListCommandr   r3   r   r   <module>r9      s3     . &  ' ( # * <e4 er   