
                         8   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  \
R                  \
R                   " \
R"                  R$                  \
R"                  R&                  5       " S S\
R(                  5      5       5       rg)z)Create Developer Connect trigger command.    )absolute_import)division)unicode_literals)cloudbuild_util)trigger_config)base)log)
properties)	resourcesc                   <    \ rS rSrSrSS0r\S 5       rS rS r	Sr
g	)
CreateDeveloperConnect   z:Create a build trigger for a Developer Connect repository.EXAMPLESa4              To create a push trigger with a DC repository for all branches:

              $ {command} --name="my-trigger" --service-account="projects/my-project/serviceAccounts/my-byosa@my-project.iam.gserviceaccount.com" --git-repository-link="projects/1234/locations/us-central1/connections/myconn/gitRepositoryLinks/mylink" --branch-pattern=".*" --build-config="cloudbuild.yaml" --region=us-central1

            To create a pull request trigger with a DC repository for main:

              $ {command} --name="my-trigger" --service-account="projects/my-project/serviceAccounts/my-byosa@my-project.iam.gserviceaccount.com" --repository="projects/1234/locations/us-central1/connections/myconn/gitRepositoryLinks/mylink" --build-config="cloudbuild.yaml" --pull-request-pattern="^main$" --region=us-central1
          c                    [         R                  " U 5      nUR                  SSS9  UR                  SS9n[         R                  " U5        [         R
                  " U5        UR                  SS9nUR                  SSSS	S
9  [         R                  " U5        [         R                  " USS9  [         R                  " U5        g)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--git-repository-linkzmDeveloper Connect resource to use, in the format "projects/*/locations/*/connections/*/gitRepositoryLinks/*".)helpTrequiredzPull Request settingsz--pull-request-patternREGEXa  Regular expression specifying which base git branch to match for
pull request events.

This pattern is used as a regex search for the base branch (the branch you are
trying to merge into) for pull request updates.
For example, --pull-request-pattern=foo will match "foo", "foobar", and "barfoo".

The syntax of the regular expressions accepted is the syntax accepted by
RE2 and described at https://github.com/google/re2/wiki/Syntax.
)metavarr   r   )require_docker_imageN)
trigger_utilsAddTriggerArgsadd_argumentadd_mutually_exclusive_groupAddBranchPatternAddTagPatternadd_argument_groupAddCommentControlArgAddBuildConfigArgsAddRepoEventArgs)parserflag_config
ref_config	pr_configs       7lib/surface/builds/triggers/create/developer_connect.pyArgsCreateDeveloperConnect.Args.   s      ..v6KL   9949HJ"":.
+--3J-KI 
	    &&y1$$[tL"";/    c                 ^   [         R                  " 5       n[        R                  " X5      u  p4U(       a  U$ UR	                  UR
                  S9Ul        UR                  nUR                  (       ad  UR                  UR                  S9Ul	        UR                  (       a4  UR                  R                  UR                  5      UR                  l        O)UR                  UR                  UR                  S9Ul        [        R"                  " X1US5        [        R$                  " X15        U$ )zParses command line arguments into a build trigger.

Args:
  args: An argparse arguments object.

Returns:
  A build trigger object.

Raises:
  RequiredArgumentException: If comment_control is defined but
  pull_request_pattern isn't.
)gitRepositoryLink)branch)r+   tag )r   GetMessagesModuler   ParseTriggerArgsDeveloperConnectEventConfiggit_repository_linkdeveloperConnectEventConfigpull_request_patternPullRequestFilterpullRequestcomment_controlCommentControlValueValuesEnumcommentControl
PushFilterbranch_patterntag_patternpushParseBuildConfigArgsParseRepoEventArgs)selfargsmessagestriggerdonecfgs         r%   ParseTriggerFromFlags,CreateDeveloperConnect.ParseTriggerFromFlagsV   s
    002H!224BMGn*2*N*N22 +O +G' 
-
-C   22** 3 co 
		&&DD$$ 	& $$$$$*:*: % ch &&whC$$W3Nr(   c           	         [         R                  " 5       n[         R                  " 5       nU R                  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
[(        R*                  " 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:
  Some values that we want to print later.
Tr   zcloudbuild.projects.locations)
collection
projectsIdlocationsId)parentbuildTriggerNz&cloudbuild.projects.locations.triggersv1)rI   rJ   
triggersId)rH   api_versionparams)r   GetClientInstancer.   rE   r
   VALUEScoreprojectGetbuildsregionDEFAULT_REGIONr   REGISTRYCreateRelativeNameprojects_locations_triggers0CloudbuildProjectsLocationsTriggersCreateRequestParseidr	   CreatedResource)r?   r@   clientrA   rB   rT   
regionproplocationrK   created_triggertrigger_resources              r%   RunCreateDeveloperConnect.Run   sA    ..0F002H((.G $$,,00$0?G""))00446J{{JjJO,J,JH&&2 '  ln	 
 88??AA 	B 	
O !))//;!#),,
	 0 	 ()r(    N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr&   rE   rf   __static_attributes__rh   r(   r%   r   r      s9     C  
- %0 %0N*X+r(   r   N)rm   
__future__r   r   r   !googlecloudsdk.api_lib.cloudbuildr   r   r   googlecloudsdk.callioper   googlecloudsdk.corer	   r
   r   UniverseCompatibleReleaseTracksReleaseTrackALPHABETACreateCommandr   rh   r(   r%   <module>r{      s}    0 &  ' = M ( # * ) D%%++T->->-C-CDNT// N E Nr(   