
    6,                     r   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 Z	 	 	 	 d-dZd Zd Zd Zd Zd Zd Zd Zd Zd.dZd/dZd.dZd.dZd.dZd.dZd.dZd.dZ d.dZ!d.dZ"d.d Z#d.d!Z$d.d"Z%d.d#Z&d.d$Z'd.d%Z(d.d&Z)d.d'Z*d.d(Z+d.d)Z,d.d*Z-d.d+Z.d.d,Z/y)0z3Flags and helpers for the compute related commands.    )absolute_import)division)unicode_literals)actions)arg_parsers)base)concepts)concept_parsers)
propertiesc                  0    t        j                  dd      S )Nregionz$The Cloud region for the {resource}.name	help_textr	    ResourceParameterAttributeConfig     5lib/googlecloudsdk/command_lib/datapipelines/flags.pyRegionAttributeConfigr      s    		2	2E
G Gr   Nc                       fd}xs dt         j                  j                  dj                  |rdnd        |       |      S )z6Constructs and returns the Pipeline Resource Argument.c                  |    fd} t        j                  dd |        t               t         j                  d      S )z?Constructs and returns the Resource specification for Pipeline.c                  2    t        j                         S )Nr   r   )arg_namer   s   r   PipelineAttributeConfigzXGetPipelineResourceArg.<locals>.GetPipelineResourceSpec.<locals>.PipelineAttributeConfig+   s    669. .r   z*datapipelines.projects.locations.pipelinespipelineF)resource_namepipelinesIdlocationsId
projectsIddisable_auto_completers)r	   ResourceSpecr    DEFAULT_PROJECT_ATTRIBUTE_CONFIG)r   r   r   s    r   GetPipelineResourceSpecz7GetPipelineResourceArg.<locals>.GetPipelineResourceSpec(   s;    .   4 +-)+<< %' 'r   z%Name for the Data Pipelines Pipeline.z{}{} z--required)r
   ConceptParserForResourceformat)r   r   
positionalr'   r$   s   ``   r   GetPipelineResourceArgr,   "   sQ    ' BB)		&	&	2	2mm*B$9	 
3 
 r   c                 6    t               j                  |        y Nr,   AddToParserparsers    r   AddCreatePipelineFlagsr3   @       &&v.r   c                 6    t               j                  |        y r.   r/   r1   s    r   AddUpdatePipelineFlagsr6   D   r4   r   c                 6    t               j                  |        y r.   r/   r1   s    r   AddDescribePipelineFlagsr8   H   r4   r   c                 6    t               j                  |        y r.   r/   r1   s    r   AddDeletePipelineFlagsr:   L   r4   r   c                 6    t               j                  |        y r.   r/   r1   s    r   AddStopPipelineFlagsr<   P   r4   r   c                 6    t               j                  |        y r.   r/   r1   s    r   AddRunPipelineFlagsr>   T   r4   r   c                 :    t        d      j                  |        y )NF)r+   r/   r1   s    r   AddListJobsFlagsr@   X   s    E*66v>r   c                     t        j                  ddt               t         j                        }t        j
                  j                  d|dj                  |      d      j                  |        y)	zAdd a resource argument for a Vertex AI region.

  NOTE: Must be used only if it's the only resource arg in the command.

  Args:
    parser: the parser for the command.
    verb: str, the verb to describe the resource, such as 'to update'.
  z datapipelines.projects.locationsr   )r   r   r    z--regionzCloud region {}.Tr&   N)	r	   r"   r   r#   r
   r(   r)   r*   r0   )r2   verbregion_resource_specs      r   AddRegionResourceArgrD   \   sh     "..(')::	< ++%	 ,  ![(r   c                 R    t        j                  d|dj                  |             S )Nz--display-namezDisplay name of the {noun}.)noun)r'   help)r   Argumentr*   )rF   r'   s     r   GetDisplayNameArgrI   r   s*    	(//T/:
< <r   c                 >    ddd}t        j                  d|| d      S )NzSpecifies a Batch pipeline.zSpecifies a Streaming pipeline.)batch	streamingz--pipeline-typez4Type of the pipeline. One of 'BATCH' or 'STREAMING'.)choicesr'   help_strr   ChoiceArgumentr'   rM   s     r   GetPipelineTypeArgrR   y   s2    ,4' 
		I	
K Kr   c                 @    ddd}t        j                  d|| dd      S )NzSpecifies a Flex template.zSpecifies a Classic template)flexclassicz--template-typeFLEXzKType of the template. Defaults to flex template. One of 'FLEX' or 'CLASSIC')rM   r'   defaultrN   rO   rQ   s     r   GetTemplateTypeArgrX      s3    */' 
		`
 r   c                 4    t        j                  d| d d      S )Nz
--schedulez?Unix-cron format of the schedule for scheduling recurrent jobs.r'   rW   rG   r   rH   r&   s    r   GetScheduleArgr\      s    	P	
 r   c                 4    t        j                  d| d d      S )Nz--time-zonezKTimezone ID. This matches the timezone IDs used by the Cloud Scheduler API.rZ   r[   r&   s    r   GetTimeZoneArgr^      s    	\	
 r   c           	      ^    t        j                  d| d t        j                  dd      d      S )Nz--template-file-gcs-location^gs://.*Must begin with 'gs://'zMLocation of the template file or container spec file in Google Cloud Storage.r'   rW   typerG   r   rH   r   RegexpValidatorr&   s    r   GetTemplateFileGcsLocationArgrf      s3    	$&&{'BD^
 r   c           	      z    t        j                  d| d dt        j                         t        j                  d      S )Nz--parameters
PARAMETERSz)User defined parameters for the template.r'   rW   metavarrc   actionrG   r   rH   r   ArgDictUpdateActionr&   s    r   GetParametersArgro      s7    	 %%:
< <r   c                 >    t        j                  d| d t        d      S )Nz--max-workerszHMaximum number of workers to run by default. Must be between 1 and 1000.rb   r   rH   intr&   s    r   GetMaxWorkersArgrs      s"    	Y
 r   c                 >    t        j                  d| d t        d      S )Nz--num-workerszInitial number of workers to run by default. Must be between 1 and 1000. If not specified here, defaults to server-specified value.rb   rq   r&   s    r   GetNumWorkersArgru      s%    	 U
 r   c                 4    t        j                  d| d d      S )Nz	--networkzDefault Compute Engine network for launching instances to run your pipeline. If not specified here, defaults to the network 'default'.rZ   r[   r&   s    r   GetNetworkArgrw      s"    	 X	
 r   c                 4    t        j                  d| d d      S )Nz--subnetworkzODefault Compute Engine subnetwork for launching instances to run your pipeline.rZ   r[   r&   s    r   GetSubnetworkArgry      s    	`	
 r   c                 4    t        j                  d| d d      S )Nz--worker-machine-typezfDefault type of machine to use for workers. If not specified here, defaults to server-specified value.rZ   r[   r&   s    r   GetWorkerMachineTypeArgr{      s    	w	
 r   c           	      ^    t        j                  d| d t        j                  dd      d      S )Nz--temp-locationr`   ra   zDefault 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://'.)rb   rd   r&   s    r   GetTempLocationArgr}      s6    	&&{'BD p
 r   c                 4    t        j                  d| d d      S )Nz--dataflow-kms-keyz`Default Cloud KMS key to protect the job resources. The key must be in same location as the job.rZ   r[   r&   s    r   GetDataflowKmsKeyArgr      s    	q	
 r   c                     t        j                  d| d t        j                  t        j
                  j                  j                        d      S )Nz--disable-public-ipszRSpecifies that Cloud Dataflow workers must not use public IP addresses by default.r'   rW   rk   rG   )r   rH   r   StoreBooleanPropertyr   VALUESdatapipelinesdisable_public_ipsr&   s    r   GetDisablePublicIpsArgr      sB    	))



)
)
<
<>c
 r   c                 4    t        j                  d| d d      S )Nz --dataflow-service-account-emailz7Default service account to run the dataflow workers as.rZ   r[   r&   s    r   !GetDataflowServiceAccountEmailArgr   	  s!    	(H	
J Jr   c                 4    t        j                  d| d d      S )Nz!--scheduler-service-account-emailzKDefault service account used by the Cloud Scheduler job for launching jobs.rZ   r[   r&   s    r   "GetSchedulerServiceAccountEmailArgr     s!    	)\	
^ ^r   c                     t        j                  d| d t        j                  t        j
                  j                  j                        d      S )Nz--enable-streaming-enginez@Specifies that enabling Streaming Engine for the job by default.r   )r   rH   r   r   r   r   r   enable_streaming_enginer&   s    r   GetEnableStreamingEngineArgr     sC    	!))



)
)
A
ACQ
 r   c           	      z    t        j                  d| d dt        j                         t        j                  d      S )Nz--additional-experimentsADDITIONAL_EXPERIMENTSz%Default experiment flags for the job.ri   )r   rH   r   ArgListrn   r&   s    r   GetAdditionalExperimentsArgr   $  s7    	 & %%6
8 8r   c           	      z    t        j                  d| d dt        j                         t        j                  d      S )Nz--additional-user-labelsADDITIONAL_USER_LABELSzDefault user labels to be specified for the job. Keys and values must follow the restrictions specified in https://cloud.google.com/compute/docs/labeling-resources#restrictions.ri   rl   r&   s    r   GetAdditionalUserLabelsArgr   /  s:    	 & %% C
 r   c                     t        j                  | d      }|j                  t        j                  d| dd             |j                  t        j                  d| dd             |S )	3Defines the Streaming Update Args for the Pipeline.T)r'   mutexz--worker-regionNzDDefault Compute Engine region in which worker processing will occur.rZ   z--worker-zonezBDefault Compute Engine zone in which worker processing will occur.)r   ArgumentGroupAddArgumentrH   )r'   worker_region_argss     r   GetWorkerRegionArgsr   ;  sk    ))84H  
mm
Y		   
mm
W		 
r   c                 :    t        j                  d| d dddg      S )Nz--flexrs-goalz&FlexRS goal for the flex template job.COST_OPTIMIZEDSPEED_OPTIMIZED)r'   rW   rG   rM   r[   r&   s    r   GetFlexRsGoalArgr   O  s(    	7!23
5 5r   c                 4   t        j                  |       }|j                  t        j                  d| t        j
                  d             |j                  t        j                  d| ddt	        j                         t        j                  d	             |S )
r   r&   z--updatez+Set this to true for streaming update jobs.)r'   rk   rG   z--transform-name-mappingsNTRANSFORM_NAME_MAPPINGSz5Transform name mappings for the streaming update job.ri   )r   r   r   rH   r   StoreTrueFalseActionrm   rn   )r'   streaming_update_argss     r   GetStreamingUpdateArgsr   X  s    ,,h?##
mm
11@	BC ##
mm
%+""$))JLM 
r   )r   NTT)F)T)0__doc__
__future__r   r   r   googlecloudsdk.callioper   r   r    googlecloudsdk.calliope.conceptsr	   (googlecloudsdk.command_lib.util.conceptsr
   googlecloudsdk.corer   r   r,   r3   r6   r8   r:   r<   r>   r@   rD   rI   rR   rX   r\   r^   rf   ro   rs   ru   rw   ry   r{   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s    : &  ' + / ( 5 D *G
 %/%)&*$(<//////?),<	K<J^8	(5r   