
    !                     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$                  5      \
R&                   " S S\
R(                  5      5       5       rg)z=Implementation of gcloud dataflow flex_template run command.
    )absolute_import)division)unicode_literals)apis)actions)arg_parsers)base)dataflow_util)
propertiesc                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
Run   z#Runs a job from the specified path.z5Runs a job from the specified flex template gcs path.z          To run a job from the flex template, run:

            $ {command} my-job --template-file-gcs-location=gs://flex-template-path --region=europe-west1 --parameters=input="gs://input",output="gs://output-path" --max-workers=5
          )DESCRIPTIONEXAMPLESc                    U R                  SSSS9  U R                  SS[        R                  " SS5      S	S
9  U R                  SSS[        R                  -   S9  U R                  SS[        R                  " SS5      S9  U R                  SS[        R                  " SS5      S9  U R                  S[        R                  " SS5      SS9  U R                  S[
        SS9  U R                  S[        R                  " [        R                  R                  R                  5      SS9  U R                  S[
        SS9  U R                  SS S!9  U R                  S"S#S!9  U R                  S$S%S!9  U R                  S&S'S!9  U R                  S(S)S!9  U R                  5       nUR                  S*S+S!9  UR                  S,S-S!9  U R                  S.[        R                  " [        R                  R                  R                  5      S/S9  U R                  S0S1[        R                  " 5       [        R                  S2S39  U R                  S4S5[        R                  " 5       [        R                  S6S39  U R                  S7S8[        R                   " 5       [        R                  S9S39  U R                  S:S;[        R                   " 5       [        R                  S<S39  U R#                  5       nUR                  S=S>[        R                   " 5       [        R                  S?S39  UR                  S@SA[        R$                  S	SB9  U R                  SCSDSESF/SG9  gH)IzfRegister flags for this command.

Args:
  parser: argparse.ArgumentParser to register arguments with.
job_nameJOB_NAMEz!Unique name to assign to the job.)metavarhelpz--template-file-gcs-locationzbGoogle Cloud Storage location of the flex template to run. (Must be a URL beginning with 'gs://'.)z^gs://.*zMust begin with 'gs://'T)r   typerequiredz--region	REGION_IDz*Region ID of the job's regional endpoint. z--staging-locationzbDefault Google Cloud Storage location to stage local files.(Must be a URL beginning with 'gs://'.))r   r   z--temp-locationzDefault Google Cloud Storage location to stage temporary files. If not set, defaults to the value for --staging-location.(Must be a URL beginning with 'gs://'.)z--service-account-emailz	.*@.*\..*z"must provide a valid email addressz&Service account to run the workers as.)r   r   z--max-workersz!Maximum number of workers to run.z--disable-public-ipsz8Cloud Dataflow workers must not use public IP addresses.)actionr   z--num-workersz!Initial number of workers to use.z--worker-machine-typezAType of machine to use for workers. Defaults to server-specified.)r   z--launcher-machine-typezKThe machine type to use for launching the job. The default isn1-standard-1.z--subnetworkzGCompute Engine subnetwork for launching instances to run your pipeline.z	--networkzDCompute Engine network for launching instances to run your pipeline.z--dataflow-kms-keyz+Cloud KMS key to protect the job resources.z--worker-regionzRegion to run the workers in.z--worker-zonezZone to run the workers in.z--enable-streaming-enginez0Enabling Streaming Engine for the streaming job.z--additional-experimentsADDITIONAL_EXPERIMENTSzkAdditional experiments to pass to the job. Example: --additional-experiments=experiment1,experiment2=value2)r   r   r   r   z--additional-pipeline-optionsADDITIONAL_PIPELINE_OPTIONSztAdditional pipeline options to pass to the job. Example: --additional-pipeline-options=option1=value1,option2=value2z--additional-user-labelsADDITIONAL_USER_LABELSzfAdditional user labels to pass to the job. Example: --additional-user-labels='key1=value1,key2=value2'z--parameters
PARAMETERSzParameters to pass to the job.z--transform-name-mappingsTRANSFORM_NAME_MAPPINGSz5Transform name mappings for the streaming update job.z--updatez+Set this to true for streaming update jobs.)r   r   r   z--flexrs-goalz&FlexRS goal for the flex template job.COST_OPTIMIZEDSPEED_OPTIMIZED)r   choicesN)add_argumentr   RegexpValidatorr
   DEFAULT_REGION_MESSAGEintr   StoreBooleanPropertyr   VALUESdataflowdisable_public_ipsadd_mutually_exclusive_groupenable_streaming_engineArgListUpdateActionArgDictadd_argument_groupStoreTrueFalseAction)parserregion_groupstreaming_update_argss      )lib/surface/dataflow/flex_template/run.pyArgsRun.Args-   s    0  2
 &8(()DF   ;223  5 8(()DF	  G 8 (()DF  G !(()MO5	  7 c(K  M ++&&99;G	  I c(K  M   
 !  
    !
   
 :  < 668L,  . *  , #++&&>>@?	  A "(  "''F  	 '-  "''J  	 "(  "''C  	   "''	)  , #557&&#)  "''	@ ' C &&;//	 '  6!#45  7    c           	         [         R                  " S0 S[        R                  R                  R
                  R                  SS9_S[        R                  " U5      _SUR                  _SUR                  _SUR                  _SUR                  _S	UR                  _S
UR                  _SUR                  _SUR                   _SUR"                  _SUR$                  _SUR&                  _S[        R                  R(                  R*                  R-                  5       _SUR.                  _SUR0                  _SUR2                  _S[        R                  R(                  R4                  R-                  5       _SUR6                  _SUR8                  _SUR:                  _SUR<                  _SUR>                  _SUR@                  _SURB                  _6n[         RD                  RG                  U5      $ )zyRuns the command.

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

Returns:
  A Job message.

project_idT)r   	region_idr   gcs_locationmax_workersnum_workersnetwork
subnetworkworker_machine_typelauncher_machine_typekms_key_namestaging_locationtemp_locationr)   service_account_emailworker_regionworker_zoner+   additional_experimentsadditional_pipeline_optionsadditional_user_labelsstreaming_updatetransform_name_mappingsflexrs_goal
parameters )$r   TemplateArgumentsr   r'   coreprojectGetr
   	GetRegionr   template_file_gcs_locationr<   r=   r>   r?   r@   rA   dataflow_kms_keyrC   rD   r(   r)   GetBoolrE   rF   rG   r+   rH   rI   rJ   updaterL   rM   rN   	TemplatesCreateJobFromFlexTemplate)selfargs	argumentss      r4   r   Run.Run   s    && $$$))1155t5D$))$/$ $ 44	$
 $$$ $$$ $ ??$ !44$ #88$ **$ ..$ (($ 	""55==?$  #88!$" ((#$$ $$%$( 	""::BBD)$*  $::+$, %)$D$D-$.  $::/$0 1$2 !% < <3$4 $$5$6 ??7$I8 >>33I>>r7   rO   N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr5   r   __static_attributes__rO   r7   r4   r   r      s5     , B		- [7 [7z%?r7   r   N)rc   
__future__r   r   r   googlecloudsdk.api_lib.dataflowr   googlecloudsdk.callioper   r   r	   #googlecloudsdk.command_lib.dataflowr
   googlecloudsdk.corer   ReleaseTracksReleaseTrackGABETAUniverseCompatibleCommandr   rO   r7   r4   <module>rr      s{    &  ' 0 + / ( = * D%%(($*;*;*@*@AQ?$,, Q?  BQ?r7   