
    v                        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 Zd Ze
j$                   e
j&                  e
j(                  j*                         G d de
j,                                      Ze
j$                   e
j&                  e
j(                  j0                         G d de                    Zy)z3Implementation of gcloud dataflow jobs run command.    )absolute_import)division)unicode_literals)apis)actions)arg_parsers)base)dataflow_util)	job_utils)
propertiesc                    t        j                  |        | j                  ddd       | j                  ddt        j                  dd      d	
       | j                  ddt        j                  dd             | j                  ddt        j
                         t        j                  d       | j                  dt        j                  t        j                  j                  j                        d       | j                  ddt        j                         t        j                  d       | j                  ddt        j
                         t        j                  d       | j                  dddt        j                  z          | j!                         }|j                  ddt        j"                  d	        |j                  d!d"t        j
                         t        j                  d#       y$)%zlRegister flags for this command.

  Args:
    parser: argparse.ArgumentParser to register arguments with.
  job_nameJOB_NAMEz%The unique name to assign to the job.)metavarhelpz--gcs-locationzeThe Google Cloud Storage location of the job template to run. (Must be a URL beginning with 'gs://'.)z^gs://.*zMust begin with 'gs://'T)r   typerequiredz--staging-locationzcThe Google Cloud Storage location to stage temporary files. (Must be a URL beginning with 'gs://'.))r   r   z--parameters
PARAMETERSz"The parameters to pass to the job.)r   r   actionr   z--enable-streaming-enginez0Enabling Streaming Engine for the streaming job.)r   r   z--additional-experimentsADDITIONAL_EXPERIMENTSzyAdditional experiments to pass to the job. These experiments are appended to any experiments already set by the template.z--additional-user-labelsADDITIONAL_USER_LABELSzfAdditional user labels to pass to the job. Example: --additional-user-labels='key1=value1,key2=value2'z--region	REGION_IDz*Region ID of the job's regional endpoint. z--updatez+Set this to true for streaming update jobs.)r   r   r   z--transform-name-mappingsTRANSFORM_NAME_MAPPINGSz5Transform name mappings for the streaming update job.N)r   
CommonArgsadd_argumentr   RegexpValidatorArgDictUpdateActionr   StoreBooleanPropertyr   VALUESdataflowenable_streaming_engineArgListr
   DEFAULT_REGION_MESSAGEadd_argument_groupStoreTrueFalseAction)parserstreaming_update_argss      lib/surface/dataflow/jobs/run.py_CommonArgsr*      s    v2  4
 	6&&{'BD   	6&&{'BD	  E 	 %%/  1 	!))



$
$
<
<>=	  ? 	 & %%G  I 	 & %%A  	 	9001  3 !335$$8--	 %  $$!' %%B %     c                    t        j                  di dt        j                  j                  j
                  j                  d      dt        j                  |       d| j                  d| j                  d| j                  d| j                  d	| j                  d
| j                  d| j                  d| j                   d| j"                  d| j$                  dt        j                  j&                  j(                  j+                         d| j,                  d| j.                  d| j0                  d| j2                  dt        j                  j&                  j4                  j+                         d| j6                  d| j8                  d| j:                  d| j<                  }| j6                  rt         j>                  jA                  |      S t         j>                  jC                  |      S )zRuns the command.

  Args:
    args: The arguments that were provided to this command invocation.

  Returns:
    A Job message.
  
project_idT)r   	region_idr   gcs_locationzonemax_workersnum_workersnetwork
subnetworkworker_machine_typestaging_locationkms_key_namedisable_public_ips
parametersservice_account_emailworker_regionworker_zoner"   streaming_updatetransform_name_mappingsadditional_experimentsadditional_user_labels )"r   TemplateArgumentsr   r    coreprojectGetr
   	GetRegionr   r/   r0   r1   r2   r3   r4   r5   r6   dataflow_kms_keyr!   r8   GetBoolr9   r:   r;   r<   r"   updater>   r?   r@   	TemplatesLaunchDynamicTemplateCreate)args	argumentss     r)   
_CommonRunrO   q   s    $$ ""''//33T3B''- }} $$	
 99 "" "" ll  22 ,, (( $**33FFNNP  !66  &&!" ""#$ )//88PPXXZ%& {{'( #::)* "88+, "88-)0 
[[>>//	::>>  ++r+   c                   &    e Zd ZdZed        Zd Zy)Run#Runs a job from the specified path.c                     t        |        y Nr*   r'   s    r)   ArgszRun.Args   
    r+   c                     t        |      S rT   rO   selfrM   s     r)   rQ   zRun.Run       dr+   N__name__
__module____qualname____doc__staticmethodrW   rQ   rA   r+   r)   rQ   rQ           , r+   rQ   c                   &    e Zd ZdZed        Zd Zy)RunBetarR   c                     t        |        y rT   rU   rV   s    r)   rW   zRunBeta.Args   rX   r+   c                     t        |      S rT   rZ   r[   s     r)   rQ   zRunBeta.Run   r]   r+   Nr^   rA   r+   r)   rf   rf      rd   r+   rf   N)rb   
__future__r   r   r   googlecloudsdk.api_lib.dataflowr   googlecloudsdk.callioper   r   r	   #googlecloudsdk.command_lib.dataflowr
   r   googlecloudsdk.corer   r*   rO   UniverseCompatibleReleaseTracksReleaseTrackGACommandrQ   BETArf   rA   r+   r)   <module>rt      s    : &  ' 0 + / ( = 9 *Pf$,N D%%(()$,,  *  D%%**+c  , r+   