
    N                     \   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  ej                  ej                  j                   ej                  j"                        ej$                   G d dej&                                      Zde	j*                  ddfdZy)z+Command for listing Cloud Run Integrations.    )absolute_import)division)unicode_literals)types_utils)base)parser_extensions)deprecation_util)flags)run_apps_operationsc                   0    e Zd ZdZdddZed        Zd Zy)ListzList Cloud Run Integrations.z"          {description}
          aN            List all Cloud Run Integrations within the current project

              $ {command}

          List all Cloud Run Integrations of a particular type

              $ {command} --type=redis

          List all Cloud Run Integrations attached to a particular Service

              $ {command} --service=my-service

         )DESCRIPTIONEXAMPLESc                 X    t        j                  |       t        j                  |       y)z\Set up arguments for this command.

    Args:
      parser: An argparse.ArgumentParser.
    N)r
   ListIntegrationsOfServiceListIntegrationsOfType)clsparsers     $lib/surface/run/integrations/list.pyArgsz	List.Args8   s      
##F+	  (    c                 
   t        j                          t        j                          t        |       |j                  }|j
                  }| j                         }|j                  d      rdnt        j                  }t        j                  ||      5 }|j                  d      r|j                          |rt        j                  |       |j                  |||t        j                        cddd       S # 1 sw Y   yxY w)aZ  Lists all the Cloud Run Integrations.

    All regions are listed by default similar to Cloud Run services unless
    a specific region is provided with the --region flag.

    Args:
      args: ArgumentParser, used to reference the inputs provided by the user.

    Returns:
      dict with a single key that maps to a list of integrations.
      This will be used by the integration_list_printer to format all
      the entries in the list.

      The reason this is not a list is because the printer will only recieve
      one entry at a time and cannot easily format all entries into a table.
    regionN)r	   CheckIfEndOfSaleAppliesDeprecationNotice
_SetFormattypeserviceReleaseTrackIsSpecifiedr   ALL_REGIONSConnectVerifyLocationr   CheckValidIntegrationTypeListIntegrationsSERVICE_TYPE)selfargsintegration_typeservice_namerelease_trackr   clients          r   RunzList.RunB   s    " ,,.&&(tyy<<L%%'M&&x0d&22  
	$	$T=	9V 
		(	#	--.>?$$
L&+2J2J 
:	9	9s   AC99DN)__name__
__module____qualname____doc__detailed_helpclassmethodr   r-    r   r   r   r      s1     %-, ) )$r   r   	namespacereturnNc                     g d}| j                         j                  dj                  dj                  |                   y )N)z'formatted_latest_resource_status:label=z"integration_name:label=INTEGRATIONzintegration_type:label=TYPEzregion:label=REGIONzservices:label=SERVICEztable({columns}),)columns)GetDisplayInfo	AddFormatformatjoin)r5   r9   s     r   r   r   i   s<    ' &&(9:r   )r1   
__future__r   r   r   'googlecloudsdk.api_lib.run.integrationsr   googlecloudsdk.callioper   r   +googlecloudsdk.command_lib.run.integrationsr	   r
   r   ReleaseTracksr   ALPHABETADefaultUniverseOnlyListCommandr   	Namespacer   r4   r   r   <module>rH      s    2 &  ' ? ( 5 H = K D%%++T->->-C-CDG4 G  EGT+55 $ r   