
                             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  G d de
j$                        Zy)zRun trigger command.    )absolute_import)division)unicode_literals)cloudbuild_util)trigger_config)base)resource_args)concept_parsers)
properties)	resourcesc                   0    e Zd ZdZdddZed        Zd Zy)RunzRun a build trigger.z_
        To run a build trigger, run:

          $ {command} MY-TRIGGER --branch=master
       )DESCRIPTIONEXAMPLESc                 H   t         j                  j                  dt        j                         dd      j                  |        | j                         }|j                  dd       |j                  dd	       |j                  d
d       t        j                  |        y )NTRIGGERzBuild Trigger.Trequiredz--branchzBranch to run.)helpz--tagzTag to run.z--shazSHA to run.)
r
   ConceptParserForResourcer	   GetTriggerResourceSpecAddToParseradd_mutually_exclusive_groupadd_argumenttrigger_utilsAddSubstitutions)parserrevision_configs     "lib/surface/builds/triggers/run.pyArgszRun.Args+   s    !!--,,.	 .  #{6*99;O  2B C  } =  } =""6*    c                 d   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"                  r"|j%                  |j"                        |	_        n[|j(                  r"|j%                  |j(                        |	_        n-|j*                  r!|j%                  |j*                  	      |	_        |j,                  rd|	j&                  |j%                         |	_        t        j.                  |j,                  |j$                  j0                        |	j&                  _        |j2                  j5                  |j6                  j9                  ||	
            S )zRuns a build trigger.

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

    Returns:
      Some value that we want to have printed later.
    Tr   )
projectsIdlocationsId
triggersIdz&cloudbuild.projects.locations.triggers)params
collection)	triggerId)
branchName)tagName)	commitSha)namerunBuildTriggerRequest)r   GetClientInstanceGetMessagesModuler   VALUEScoreprojectGetbuildsregionDEFAULT_REGIONr   r   REGISTRYParseRelativeNameRunBuildTriggerRequestbranch
RepoSourcesourcetagshasubstitutionsEncodeTriggerSubstitutionsSubstitutionsValueprojects_locations_triggersr   MESSAGES_MODULE-CloudbuildProjectsLocationsTriggersRunRequest)
selfargsclientmessagesr3   
regionproplocationtriggerr-   requests
             r    r   zRun.Run9   s    ..0F002H$$,,00$0?G""))00446J{{JjJO,J,JHllG##!#!

 < $ = >J\^ 	 ---@G{{**dkk*Bgn	**488*<gn	**TXX*>gn		!,,.%4%O%O


h11DD&Fgnn" --11LL#* 	M 	
 r"   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr!   r    r"   r    r   r      s/     !- + +/r"   r   N)rR   
__future__r   r   r   !googlecloudsdk.api_lib.cloudbuildr   r   r   googlecloudsdk.callioper   %googlecloudsdk.command_lib.cloudbuildr	   (googlecloudsdk.command_lib.util.conceptsr
   googlecloudsdk.corer   r   Commandr   rU   r"   r    <module>r]      s:     &  ' = M ( ? D * )J$,, Jr"   