
    ~                         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\
R                  5      rS rg)zCreate manual trigger command.    )absolute_import)division)unicode_literals)cloudbuild_util)trigger_config)base)log)
properties)	resourcesc                   6    \ rS rSrSrSS0r\S 5       rS rSr	g)	CreateManual   z3Create a build trigger with a manual trigger event.EXAMPLESaR              To create a manual trigger that builds off branch `my-branch` in a GitHub repository named `my-repo`:

              $ {command} --name=my-manual-trigger --build-config=cloudbuild.yaml --repo=https://www.github.com/owner/repo --repo-type=GITHUB --branch=my-branch

            To create a manual trigger that builds off branch `my-branch` in a 2nd-gen GitHub repository resource:

              $ {command} --name=my-manual-trigger --build-config=cloudbuild.yaml --repository=projects/my-proj/locations/us-west1/connections/my-conn/repositories/my-repo --branch=my-branch
          c                     [         R                  " U 5      n[         R                  " U5        [         R                  " U5        g)zZRegister flags for this command.

Args:
  parser: An argparse.ArgumentParser-like object.
N)trigger_utilsAddTriggerArgsAddBuildConfigArgsAddGitRepoSource)parserflag_configs     ,lib/surface/builds/triggers/create/manual.pyArgsCreateManual.Args-   s0      ..v6K$$[1"";/    c           	      \   [         R                  " 5       n[         R                  " 5       nUR                  5       nUR                  (       a-  [         R
                  " UR                  UR                  SS/S9nO[        U5      n[        R                  R                  R                  R                  SS9n[        R                  R                  R                  R                  5       nUR                  =(       d    U=(       d    [         R                  n[        R                   R#                  SUUS9R%                  5       nUR&                  R#                  UR)                  XS95      n	[        R                   R+                  S	S
SUUU	R,                  S.S9n
[.        R0                  " U
5        U	$ )zThis is what gets called when the user runs this command.

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

Returns:
  The newly created trigger.
zbuild trigger configsubstitutions)pathmsg_typemsg_friendly_nameskip_camel_caseTrequiredzcloudbuild.projects.locations)
collection
projectsIdlocationsId)parentbuildTriggerNz&cloudbuild.projects.locations.triggersv1)r$   r%   
triggersId)r#   api_versionparams)r   GetClientInstanceGetMessagesModuleBuildTriggerr   LoadMessageFromPathParseTriggerFromFlagsr
   VALUEScoreprojectGetbuildsregionDEFAULT_REGIONr   REGISTRYCreateRelativeNameprojects_locations_triggers0CloudbuildProjectsLocationsTriggersCreateRequestParseidr	   CreatedResource)selfargsclientmessagestriggerr3   
regionproplocationr&   created_triggertrigger_resources              r   RunCreateManual.Run9   s    ..0F002H##%G33""((2*+	-g &d+g $$,,00$0?G""))00446J{{JjJO,J,JH&&2 '  +ln  88??AA 	B 	12O !))//;!#),,
	 0  ()r    N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   rI   __static_attributes__rK   r   r   r   r      s/    ; - 	0 	0/r   r   c                 L   [         R                  " 5       n[        R                  " X5      u  p#U(       a  U$ U R                  Ul        [
        R                  R                  R                  R                  SS9nSU< SU R                  < S3n[        R                  " X XSS9  U$ )zParse arguments into a BuildTrigger proto.

Args:
  args: An argparse.Namespace. All the arguments that were provided to this
    command invocation.

Returns:
  A BuildTrigger proto object.
Tr!   zgcr.io/z/gcb-z:$COMMIT_SHA)	need_repo)r   r-   r   ParseTriggerArgsnamer
   r1   r2   r3   r4   ParseBuildConfigArgs)rA   rC   rD   doner3   default_images         r   r0   r0   k   s     ..0(00@-'	N', ""**...='4;TYYG-$$X> 
.r   N)rP   
__future__r   r   r   !googlecloudsdk.api_lib.cloudbuildr   r   r   googlecloudsdk.callioper   googlecloudsdk.corer	   r
   r   CreateCommandr   r0   rK   r   r   <module>r`      s?    % &  ' = M ( # * )K4%% K\r   