
    D	                         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
 ej                   G d d	ej                               Zy
)zFCommand to list all Apigee organizations to which the user has access.    )absolute_import)division)unicode_literals)apigee)base)
propertiesc                   0    e Zd ZdZdddZed        Zd Zy)ListzCList Apigee organizations and their paired Cloud Platform projects.aG    {description}

  `{command}` lists all organizations to which the user's `gcloud auth`
  credentials have access, even if they don't match the active Cloud Platform
  project.

  Apigee organizations are distinct from Cloud Platform organizations, and
  usually have a one-to-one relationship with Cloud Platform projects.
  a!    To list all accessible organizations and their associated Cloud Platform projects, run:

      $ {command}

  To get a JSON array of all organizations whose Cloud Platform project names
  contain the word ``sandbox'', run:

      $ {command} --format=json --filter="project:(sandbox)"
  )DESCRIPTIONEXAMPLESc                 :    | j                   j                  d       y )Nztable(name, project.flatten()))display_info	AddFormat)parsers    (lib/surface/apigee/organizations/list.pyArgsz	List.Args5   s    
!!"BC    c              #   6  K   t         j                  j                  j                  j	                         r)t        j
                  j                  t        |            }nt        j
                  j                         }d|v r|d   D ]  }|d   |d   d  yyw)zRun the list command.organizationsorganization
projectIds)nameprojectN)	r   VALUESapi_endpoint_overridesr   GetOrganizationsClientr
   varsListOrganizationsGlobal)selfargsresultr   s       r   RunzList.Run9   s     //66::<))..tDz:f))AACf&  1, 0#L1
 	
 2 !s   BBN)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r#    r   r   r
   r
      s1    K		-0 D D
r   r
   N)r'   
__future__r   r   r   googlecloudsdk.api_libr   googlecloudsdk.callioper   googlecloudsdk.corer   UniverseCompatibleListCommandr
   r*   r   r   <module>r1      sD    M &  ' ) ( * *
4 *
 *
r   