
    _                     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 dd
lmZ ddlmZ ej*                   ej,                  ej.                  j0                  ej.                  j2                        ej4                   G d dej6                                             Zy)zIShows the logs for an in-progress or completed PipelineRun/TaskRun/Build.    )absolute_import)division)unicode_literals)cloudbuild_util)logs)client_util)base)	run_flags)
properties)	resourcesc                   &    e Zd ZdZed        Zd Zy)Logz.Show the logs for a PipelineRun/TaskRun/Build.c                 X    | j                  dddd       t        j                  |       } y)zRegister flags for this command.

    Args:
      parser: An argparse.ArgumentParser-like object. It is mocked out in order
        to capture some information, but behaves like an ArgumentParser.
    z--streamzGIf a run is ongoing, stream the logs to stdout until the run completes.F
store_true)helpdefaultactionN)add_argumentr
   AddsRunFlags)parsers    lib/surface/builds/runs/log.pyArgszLog.Args%   s7     #   ##F+F    c           	      @   |j                   j                  j                         }|j                         d   }t        j
                  j                  j                  j                  d      }|j                  }|j                  dk(  rt        j                         }t        j                         }t        j                  j                  ||||dd      }t!        j"                  ||d      }	|j$                  r|	j'                  |       y|	j)                  |       yt+        j                         }t+        j                         }|j                  d	k(  r8t        j                  j                  |d
d|||d      }
|
j-                         }n7t        j                  j                  |dd|||d      }|j-                         }t/        j0                         }	|j$                  r|	j'                  ||||j                         y|	j)                  ||||j                         y)z9This is what gets called when the user runs this command.locationsIdT)requiredbuild)
projectsIdr   buildsIdz$cloudbuild.projects.locations.builds)params
collectionNpipelinerunz*cloudbuild.projects.locations.pipelineRunsv2)r   r   pipelineRunsId)r!   api_versionr    z&cloudbuild.projects.locations.taskRuns)r   r   
taskRunsId)CONCEPTSregionParseAsDictr   VALUEScoreprojectGetRUN_IDtypev1_client_utilGetClientInstanceGetMessagesModuler   REGISTRYv1_logsCloudBuildClientstreamStreamPrintLogv2_client_utilNamev2_logsCloudBuildLogClient)selfargs
region_refr(   r-   run_idclientmessages	build_refloggerpipeline_run_resourcetask_run_resources               r   RunzLog.Run5   s   %%++-J /F$$,,00$0?G[[FyyG//1f113h$$**
## 
 < + =i ''$?f	i ooi //1f113h	m	# ) 2 2 8 8C%%"(	 !9 ! '++-%..44?%%$	 5  #'')**,f	gvvtyy9oogvvtyy9r   N)__name__
__module____qualname____doc__staticmethodr   rH    r   r   r   r      s     7, ,5r   r   N)rL   
__future__r   r   r   !googlecloudsdk.api_lib.cloudbuildr   r1   r   r5   $googlecloudsdk.api_lib.cloudbuild.v2r   r:   r<   googlecloudsdk.callioper	   %googlecloudsdk.command_lib.cloudbuildr
   googlecloudsdk.corer   r   HiddenReleaseTracksReleaseTrackALPHABETAUniverseCompatibleCommandr   rN   r   r   <module>r\      s    P &  ' O = N @ ( ; * ) D%%++T->->-C-CDH$,, H  E Hr   