
                            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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\R6                  " 5       r\" S\R:                  " 5       05      r " S S\R>                  5      r  SS\\
RB                     S\RD                  4S jjr#g)zJob-specific printer.    )absolute_import)division)print_function)unicode_literals)Optional)
frozendict)types_utils)deployment_states)base)custom_domains_formatter)default_formatter)states)console_attr)custom_printer_base)runapps_v1alpha1_messagesintegrationzcustom-domainsc                       \ rS rSrSrS\R                  S\R                  4S jr	S\R                  4S jr
S\R                  S\R                  S\4S	 jrS
rg)IntegrationPrinter,   z=Prints the run Integration in a custom human-readable format.recordreturnc                    [        UR                  5      nUR                  U5      nUR                  R                  (       a  UR                  U5      OSnU R                  U5      SU R                  UR                  U5      US[        R                  " [        R                  " SU/5      /5      /nUR                  U5      nU(       a"  UR                  S5        UR                  U5        [        R                  " U5      $ )zETransform an integration into the output structure of marker classes.zStatus not available zIntegration Components)GetFormattermetadataTransformConfigstatusresourceComponentStatusesTransformComponentStatusHeader_DeploymentProgresslatest_deploymentcpLabeledLinesCallToActionappend)selfr   	formatterconfig_blockcomponent_blocklinescall_to_actions          Flib/googlecloudsdk/command_lib/run/integrations/integration_printer.py	TransformIntegrationPrinter.Transform/   s    V__-I,,V4L ==22 	**62#  	F  !9!9!*	,


HH( 
 	E ++F3Nll3ll>"88E?    c                    [         R                  " 5       n[        UR                  5      n[        R
                  nUR                  (       a:  UR                  R                  (       a  [        UR                  R                  5      nUR                  U5      nUR                  SR                  XQR                  UR                  5      5      $ )zmPrint the header of the integration.

Args:
  record: dict, the integration.

Returns:
  The printed output.
z&{} Integration status: {} in region {})r   GetConsoleAttrr   r   r   UNKNOWNr   statestrStatusSymbolAndColor	Emphasizeformatnameregion)r(   r   conr)   resource_statesymbols         r.   r    IntegrationPrinter.HeaderN   s     
%
%
'CV__-I^^N}},,6==../n++N;F==077KK	
 r1   
deploymentr)   c                     Uc  g[        UR                  R                  5      nU[        R                  :X  aF  UR                  R
                  nUR                  [        R                  5      nSR                  XT5      $ g)a  Returns a message denoting the deployment progress.

If there is no ongoing deployment and the deployment was successful, then
this will be empty.

Currently this only shows something if the latest deployment was a failure.
In the future this will be updated to show more granular statuses as the
deployment is ongoing.

Args:
  deployment:  The deployment object
  formatter: The specific formatter used for the integration type.

Returns:
  The message denoting the most recent deployment's progress (failure).
 z"{} Latest deployment: FAILED - {}
)	r6   r   r5   r
   FAILEDerrorMessager7   r   r9   )r(   r@   r)   r5   reasonr>   s         r.   r!   &IntegrationPrinter._DeploymentProgressc   sk    * 
!!''(E!(((  --f--fmm<f299&IIr1    N)__name__
__module____qualname____firstlineno____doc__r   Recordr#   _Markerr/   r    runapps
DeploymentBaseFormatterr6   r!   __static_attributes__rG   r1   r.   r   r   ,   s]    Edkk bjj >4;; *$$ ## 	r1   r   Nr   r   c                 d    U (       d  [         $ [        R                  U R                  [         5      $ )zReturns the formatter for the given integration type.

Args:
  metadata: the typekit metadata for the integration.

Returns:
  A formatter object.
)_DEFAULT_FORMATTER_INTEGRATION_FORMATTER_MAPSgetintegration_type)r   s    r.   r   r      s+     
,,	$	(	()B)B);
= =r1   )N)$rL   
__future__r   r   r   r   typingr   r   'googlecloudsdk.api_lib.run.integrationsr	   +googlecloudsdk.command_lib.run.integrationsr
   6googlecloudsdk.command_lib.run.integrations.formattersr   r   r   r   googlecloudsdk.core.consoler   googlecloudsdk.core.resourcer   r#   6googlecloudsdk.generated_clients.apis.runapps.v1alpha1r   rO   INTEGRATION_PRINTER_FORMATDefaultFormatterrT   CustomDomainsFormatterrU   CustomPrinterBaser   TypeMetadatarQ   r   rG   r1   r.   <module>re      s     &  % '  ! ? I G [ T I 4 B g + &779 (.EEG*  
V-- Vt 48={//0=	=r1   