
                            S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SS	KJr  S
 r " S S\5      r " S S\5      r\	R$                  " \	R&                  R(                  5       " S S\\	R*                  5      5       r\	R$                  " \	R&                  R.                  5       " S S\\	R*                  5      5       rg)z2Implementation of connection profile list command.    )absolute_import)division)unicode_literals)connection_profiles)resource_args)base)concept_parsers)
propertiesc                 `    [         R                  " U 5      R                  UR                  5      $ )z/Gets the resource URI for a connection profile.)r   ConnectionProfilesClientGetUriname)release_trackconnection_profile_infos     :lib/surface/database_migration/connection_profiles/list.py_GetUrir      s+     
	5	5m	D	K	K""
$ $    c                       \ rS rSrSrS rSrg)_ConnectionProfileInfo#   z<Container for connection profile data using in list display.c                 \   UR                   U l        UR                  U l        UR                  U l        UR                  U l        X l        UR                  U l        X0l	        UR                  (       a:  UR                  (       d  SU l        SR                  U R
                  S5      U l        g g )NCLOUDSQLz{}_{}REPLICA)displayNamedisplay_namer   stateproviderprovider_displayhost
createTimecreate_timeenginecloudsqlformat)selfmessager   r"   s       r   __init___ConnectionProfileInfo.__init__&   s    ++DDIDJ#,,DI))DK *%nnT-B-BINd r   )r!   r   r"   r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r'   __static_attributes__ r   r   r   r   #   s    DOr   r   c                   .    \ rS rSrSr\S 5       rS rSrg)_List7   zFBase class for listing Database Migration Service connection profiles.c                    ^  [         R                  R                  S[        R                  " 5       SS9R                  U5        UR                  R                  S5        UR                  R                  U 4S j5        g)z Register flags for this command.z--regionz:The location you want to list the connection profiles for.)
group_helpa[  
          table(
            name.basename():label=CONNECTION_PROFILE_ID,
            display_name,
            name.scope('locations').segment(0):label=REGION,
            state,
            provider_display:label=PROVIDER,
            engine,
            host:label=HOSTNAME/IP,
            create_time.date():label=CREATED
          )
        c                 8   > [        TR                  5       U 5      $ N)r   ReleaseTrack)pclss    r   <lambda>_List.Args.<locals>.<lambda>P   s    WS5E5E5G-Kr   N)	r	   ConceptParserForResourcer   GetRegionResourceSpecAddToParserdisplay_info	AddFormat
AddUriFunc)r9   parsers   ` r   Args
_List.Args:   sl     !!--++-O .  k&
!! #  ""#KLr   c           
         [         R                  " U R                  5       5      n[        R                  R
                  R                  R                  SS9nUR                  X15      nUR                  b   UR                  R                  S5      (       a;  U Vs/ s H-  n[        XPR                  U5      UR                  U5      5      PM/     sn$ U$ s  snf )zRuns the command.

Args:
  args: All the arguments that were provided to this command invocation.

Returns:
  An iterator over objects containing connection profile data.
T)requiredz"table)r   r   r7   r
   VALUEScoreprojectGetListr$   
startswithr   _GetHostGetEngineName)r%   args	cp_client
project_idprofilesprofiles         r   Run	_List.RunR   s     $<<I""''//33T3BJ~~j/H{{dkk44X>> " "g !--*@!*!8!8!AC! 
 Os   4Cr/   N)	r)   r*   r+   r,   r-   classmethodrD   rU   r.   r/   r   r   r1   r1   7   s    NM M.r   r1   c                       \ rS rSrSrS rSrg)	ListAlphai   a  List Database Migration Service connection profiles.

List connection profiles.

## API REFERENCE
  This command uses the datamigration/v1alpha2 API. The full documentation
  for this API can be found at: https://cloud.google.com/database-migration/

## EXAMPLES
  To list all connection profiles in a project and region ``us-central1'',
  run:

      $ {command} --region=us-central1

  To filter connection profiles with the given state:

      $ {command} --filter="state=READY"
c                    UR                   (       a  UR                   R                  $ UR                  (       aG  UR                  R                  (       a  UR                  R                  $ UR                  R                  $ g r6   )mysqlr   r#   publicIp	privateIpr%   rT   s     r   rN   ListAlpha._GetHost~   s`    }}]]			!!** '' /##--/ r   r/   Nr)   r*   r+   r,   r-   rN   r.   r/   r   r   rY   rY   i   s    &r   rY   c                       \ rS rSrSrS rSrg)ListGA   a  List Database Migration Service connection profiles.

List connection profiles.

## API REFERENCE
  This command uses the datamigration/v1 API. The full documentation
  for this API can be found at: https://cloud.google.com/database-migration/

## EXAMPLES
  To list all connection profiles in a project and region 'us-central1', run:

      $ {command} --region=us-central1

  To filter connection profiles with the given state:

      $ {command} --filter="state=READY"
c                    UR                   (       a  UR                   R                  $ UR                  (       a  UR                  R                  $ UR                  (       aG  UR                  R                  (       a  UR                  R                  $ UR                  R
                  $ UR                  (       a*  UR                  R                  R                  R
                  $ UR                  (       a  UR                  R                  $ g r6   )
r\   r   
postgresqlr#   r]   r^   alloydbsettingsprimaryInstanceSettingsoracler_   s     r   rN   ListGA._GetHost   s    }}]]			$$$			!!** '' /##--/ 
__%%==GGG	^^   r   r/   Nra   r/   r   r   rc   rc      s    $r   rc   N)r-   
__future__r   r   r   )googlecloudsdk.api_lib.database_migrationr   r   googlecloudsdk.callioper   (googlecloudsdk.command_lib.util.conceptsr	   googlecloudsdk.corer
   r   objectr   r1   ReleaseTracksr7   ALPHAListCommandrY   GArc   r/   r   r   <module>rv      s    9 &  ' I C ( D *$OV O(/F /d D%%++,t''  -> D%%(()"UD$$ " *"r   