
    -                         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g)z+Export Cloud Build trigger to file command.    )absolute_import)division)unicode_literals)
exceptions)cloudbuild_util)base)flags)
properties)	resourcesc                   J    \ rS rSrSrSSS.r\S 5       rS rS r	S	 r
S
 rSrg)Import   zImport a build trigger.z        To import a trigger from a file:
        $ cat > trigger.yaml <<EOF
        name: my-trigger
        github:
          owner: GoogleCloudPlatform
          name: cloud-builders
          push:
            branch: .*
        EOF
          z|
        To import a build trigger from a file called trigger.yaml, run:

          $ {command} --source=trigger.yaml
      )DESCRIPTIONEXAMPLESc                 T    [         R                  " U 5        U R                  SSSSS9  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--sourcePATHTz9File path where trigger should be imported from.
        )metavarrequiredhelpN)build_flagsAddRegionFlagadd_argument)parsers    %lib/surface/builds/triggers/import.pyArgsImport.Args4   s3     f%
	      c                    UR                   nU(       d  UR                  n[        R                  R	                  UR                   UUUS.SS9R                  5       nXul        UR                  R                  UR                  XvUS95      $ )N)
projectsIdlocationsId
triggersIdz&cloudbuild.projects.locations.triggers)params
collection)resourceName	triggerIdbuildTrigger)
idnamer   REGISTRYParseRelativeNamer$   projects_locations_triggersPatch/CloudbuildProjectsLocationsTriggersPatchRequest)selfclientmessages
project_idlocation_idtrigger
trigger_idr(   s           r   _UpdateTriggerImport._UpdateTriggerF   s    J<<j##

$&$

 < $ = >J\^ 	  --33@@' 	A 	KL Lr   c                     [         R                  R                  SUUS9R                  5       nUR                  R                  UR                  XeS95      $ )Nzcloudbuild.projects.locations)r#   r   r    )parentr&   )r   r)   Creater+   r,   0CloudbuildProjectsLocationsTriggersCreateRequest)r/   r0   r1   projectlocationr4   r9   s          r   _CreateTriggerImport._CreateTriggerX   sd    &&2 '  +ln 
 --44AA 	B 	12 2r   c                    UR                   (       a  U R                  XX4U5      $ UR                  (       a   U R                  XX4U5      $ U R                  XX4U5      $ ! [        R                   a    U R                  XX4U5      s $ f = f)N)r'   r6   r(   apitools_exceptionsHttpNotFoundErrorr>   )r/   r0   r1   r<   r=   r4   s         r   _CreateOrUpdateTriggerImport._CreateOrUpdateTriggerb   s    zz  7gNN	Q""6WPP   7gNN !22 Q""6WPPQs   A 'BBc           
         [         R                  " 5       n[         R                  " 5       n[        R                  R
                  R                  R                  SS9n[        R                  R                  R                  R                  5       nUR                  =(       d    U=(       d    [         R                  n[         R                  " UR                  UR                  SS/S9nU Vs/ s H  nU R                  X#XFU5      PM     sn$ s  snf )zImports 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.
T)r   BuildTriggersubstitutions)skip_camel_case)r   GetClientInstanceGetMessagesModuler
   VALUEScorer<   GetbuildsregionDEFAULT_REGIONLoadMessagesFromPathsourcerF   rC   )	r/   argsr0   r1   r<   
regionpropr=   triggersr4   s	            r   Run
Import.Runt   s     ..0F002H$$,,00$0?G""))00446J{{JjJO,J,JH33()	+H =E<D 	##Fg$+	-<D  s   *D
 N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   r6   r>   rC   rV   __static_attributes__rX   r   r   r   r      s@    

-(  "L$2O$r   r   N)r]   
__future__r   r   r   apitools.base.pyr   rA   !googlecloudsdk.api_lib.cloudbuildr   googlecloudsdk.callioper   !googlecloudsdk.command_lib.buildsr	   r   googlecloudsdk.corer
   r   Commandr   rX   r   r   <module>rh      s7    2 &  ' > = ( B * )pT\\ pr   