
                         >   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 ddlmZ  e
j*                  e
j,                  j.                  e
j,                  j0                         G d de
j2                               Zy)z+Export Cloud Build trigger to file command.    )absolute_import)division)unicode_literals)encoding)cloudbuild_util)base)resource_args)concept_parsers)
properties)	resources)yaml)filesc                   .    e Zd ZdZddiZed        Zd Zy)ExportzExport a build trigger.EXAMPLESz
        To export a build trigger to a file called trigger.yaml, run:

          $ {command} MY-TRIGGER --destination=trigger.yaml
      c                     t         j                  j                  dt        j                         dd      j                  |        | j                  dddd       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.
    TRIGGERzBuild Trigger.Trequiredz--destinationPATHz4File path where trigger should be exported.
        )metavarr   helpN)r
   ConceptParserForResourcer	   GetTriggerResourceSpecAddToParseradd_argument)parsers    %lib/surface/builds/triggers/export.pyArgszExport.Args,   s_     !!--,,.	 .  #{6*
	      c                    t        j                         }t        j                         }t        j                  j
                  j                  j                  d      }t        j                  j                  j                  j                         }|j                  xs |xs t         j                  }|j                  }t        j                  j                  ||||dd      j                         }|j                   j                  |j#                  ||            }	t%        j&                  |j(                        5 }
t+        j,                  t/        j0                  |	      |
       ddd       y# 1 sw Y   yxY w)	zExports a build trigger.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.
    Tr   )
projectsIdlocationsId
triggersIdz&cloudbuild.projects.locations.triggers)params
collection)name	triggerId)streamN)r   GetClientInstanceGetMessagesModuler   VALUEScoreprojectGetbuildsregionDEFAULT_REGIONr   r   REGISTRYParseRelativeNameprojects_locations_triggers-CloudbuildProjectsLocationsTriggersGetRequestr   
FileWriterdestinationr   dumpr   MessageToDict)selfargsclientmessagesr/   
regionproplocationtriggerr(   got_triggerouts              r   Runz
Export.RunC   s2    ..0F002H$$,,00$0?G""))00446J{{JjJO,J,JHllG##!#!

 < $ = >J\^ 	 4488>> 	? 	*+K 
		$**	+s
ii&&{3C@ 
,	+	+s   <+E00E9N)__name__
__module____qualname____doc__detailed_helpstaticmethodr    rF    r!   r   r   r       s0      
-  ,Ar!   r   N)rJ   
__future__r   r   r   apitools.base.pyr   !googlecloudsdk.api_lib.cloudbuildr   googlecloudsdk.callioper   %googlecloudsdk.command_lib.cloudbuildr	   (googlecloudsdk.command_lib.util.conceptsr
   googlecloudsdk.corer   r   r   googlecloudsdk.core.utilr   ReleaseTracksReleaseTrackALPHABETACommandr   rM   r!   r   <module>r[      sx    2 &  ' % = ( ? D * ) $ * D%%++T->->-C-CD>AT\\ >A E>Ar!   