
    w%                     D   d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddd	Z G d
 dej                        Z
 G d dej                        Z G d de      ZdedfiZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd&dZd Z	 	 	 d'dZd(d Zd! Zd" Zd# Zd$ Z d% Z!y))z,Flags and helpers for the Managed Flink CLI.    N)arg_parsers)base)
completers)parameter_info_libz$The number of taskmanagers is fixed.zIThe number of taskmanagers is scaled automatically according to workload.)fixedelasticc                   *     e Zd ZdZ	 	 	 d fd	Z xZS )ListCommandParameterInfoz&Helper class for ListCommandCompleter.c                 2    t         t        |   ||||      S )N)check_properties
for_update)superr
   GetFlag)selfparameter_nameparameter_valuer   r   	__class__s        5lib/googlecloudsdk/command_lib/managed_flink/flags.pyr   z ListCommandParameterInfo.GetFlag%   s+     )48)	 9      )NTF)__name__
__module____qualname____doc__r   __classcell__r   s   @r   r
   r
   "   s    .
  r   r
   c                       e Zd ZdZd Zy)ListCommandCompleterz%Helper class for DeploymentCompleter.c                 <    t        ||| j                  t              S )N)updaters)r
   
collectionCOMPLETERS_BY_CONVENTION)r   parsed_args	argumentss      r   ParameterInfoz"ListCommandCompleter.ParameterInfo7   s    #)	 r   N)r   r   r   r   r$    r   r   r   r   4   s
    -r   r   c                   "     e Zd ZdZ fdZ xZS )DeploymentCompleterz"Completer for listing deployments.c                 2    t        t        | 
  dddd| y )Nz+managedflink.projects.locations.deploymentszmanaged-flink deployments list)r    list_commandr%   )r   r'   __init__)r   kwargsr   s     r   r*   zDeploymentCompleter.__init__C   s(    	
t- @5 r   )r   r   r   r   r*   r   r   s   @r   r'   r'   @   s    * r   r'   
deploymentFc                 X    | j                  dddd       | j                  dddd	       y
)zAdds network config arguments.z--network-config-vpcNETWORKnetworkzThe network to use for the job.metavardesthelpz--network-config-subnetwork
SUBNETWORK
subnetworkz"The subnetwork to use for the job.Nadd_argumentparsers    r   AddNetworkConfigArgsr:   O   sB    ,	   	#/	  r   c                 .    | j                  dddd       y)z Adds workload identity argument.z--workload-identityWORKLOAD_IDENTITYworkload_identityzpThe workload identity to use for the job. Managed Flink Default Workload Identity will be used if not specified.r0   Nr6   r8   s    r   AddWorkloadIdentityArgumentr>   _   s$    !F  r   c                 Z    t        j                  dddddgd      j                  |        y)	zCreates location argument.z
--locationLOCATIONTlocationz--regionzThe location to run the job in.)r1   requiredr2   suggestion_aliasesr3   Nr   ArgumentAddToParserr8   s    r   AddLocationArgumentrG   l   s.    --$, Kr   c                 Z    t        j                  ddg ddd      j                  |        y)zJob type arguments.z
--job-typeJOB_TYPE)autojarpythonsqlrJ   zdThe type of job to run. If "auto" will be selected based on the file extension for the job argument.)r1   choicesdefaultr3   NrD   r8   s    r   AddJobTypeArgumentrP   x   s+    --.-	 Kr   c                 R    t        j                  ddd      j                  |        y)zCreates the job argument.jobz
JAR|PY|SQLzLThe file containing the Flink job to run. Can be a jar, python, or sql file.r1   r3   NrD   r8   s    r   AddJobJarArgumentrT      s%    --	 Kr   c                 z    t        j                  ddt        j                         dd      j	                  |        y)z Creates the extra jars argument.z--jarsJAR
extra_jarszEThe extra jars to pass to the job. Can be a jar, python, or sql file.r1   typer2   r3   Nr   rE   r   ArgListrF   r8   s    r   AddExtraJarsArgumentr\      s4    -- 	 Kr   c                 X    t        j                  dddddd      j                  |        y)zCreates dry run argument.z	--dry-run
store_truedry_runFz9Return command used to submit a job without invoking API.actionr2   rO   rB   r3   NrD   r8   s    r   AddDryRunArgumentrb      s,    --F Kr   c                 T    t        j                  dddd      j                  |        y)Creates main class argument.z--classCLASS
main_classzaThe main class of the Flink job. Required if the jar file manifest does not contain a main class.r0   NrD   r8   s    r   AddMainClassArgumentrg      s(    --, Kr   c                 H    | j                  dt        j                  d       y)z0Collects extra arguments into the job_args list.job_argszThe job arguments to pass.)nargsr3   N)r7   argparse	REMAINDERr8   s    r   AddJobArgsCollectorrm      s$    '  r   c                 V    t        j                  ddddd      j                  |        y)zCreates name argument.z--nameNAMEnameFz@The name of the job. The Flink job name will be used if not set.r1   r2   rB   r3   NrD   r8   s    r   AddNameArgumentrr      s)    --M Kr   c                 R    t        j                  ddd      j                  |        y)zCreates job id argument.job_idJOBIDzThe id of the job.rS   NrD   r8   s    r   AddJobIdArgumentrv      s#    -- Kr   c                 X    t        j                  ddd|dd      j                  |        y)zCreates async argument.z--asyncr^   async_submitFz(Return immediately after job submission.r`   NrD   )r9   rO   s     r   AddAsyncArgumentry      s,    --5 Kr   c                 V    t        j                  ddddd      j                  |        y)z"Creates staging location argument.z--staging-locationSTAGING_LOCATIONstaging_locationTzLThe Google Cloud Storage staging location for the job. Must start with gs://rq   NrD   r8   s    r   AddStagingLocationArgumentr}      s+    -- 	 Kr   c                     |r|}nd}|rdj                  ||f      }t        j                  dd|dt        |      j	                  |        y)zCreates deployment argument.z:
    The Flink Deployment to use for this invocation.
    z

z--deploymentDEPLOYMENT_NAMEr,   )r1   rB   r2   	completerr3   N)joinr   rE   r'   rF   )r9   help_text_to_prependhelp_text_to_overwriterB   	help_texts        r   AddDeploymentArgumentr      sV     &II 19=>I--# Kr   c           	      b    t        j                  ddt        ||dd      j                  |        y)z!Creates autotuning mode argument.z--autotuning-modeAUTOTUNING_MODEautotuning_modez%Selects the autotuning mode for jobs.)r1   rN   rO   rB   r2   r3   N)r   rE   _AUTOTUNING_MODESrF   )r9   rO   rB   s      r   AddAutotuningModeArgumentr     s1     --2 Kr   c                 V    | j                  dt        j                  dd      d       y)z!Adds fixed parallelism arguments.z--parallelism   '  lower_boundupper_boundz;The parallelism of the job when in "fixed" autotuning mode.rY   r3   Nr7   r   
BoundedIntr8   s    r   AddFixedParallelismArgsr   '  s+    !!aUCH  r   c                     | j                  dt        j                  dd      d       | j                  dt        j                  dd      d       y	)
z#Adds elastic parallelism arguments.z--min-parallelismr   r   r   z{The minimum parallelism of the job when in "elastic" autotuning mode. This will also be the initial parallelism of the job.r   z--max-parallelismzEThe maximum parallelism of the job when in "elastic" autotuning mode.Nr   r8   s    r   AddElasticParallelismArgsr   0  s[    !!aUCI	   	!!aUC	  r   c                 X    t        j                  dddddd      j                  |        y)zCreates show output argument.z--enable-outputr^   show_outputFz%Shows the output of the Flink client.r`   NrD   r8   s    r   AddShowOutputArgumentr   D  s,    --2 Kr   c                 z    t        j                  ddt        j                         dd      j	                  |        y)z$Creates the extra archives argument.z
--archivesZIParchivesz_The extra archives to pass to the job. Can be a zip file containing resource files for the job.rX   NrZ   r8   s    r   AddExtraArchivesArgumentr   P  s4    -- )	 Kr   c                 T    t        j                  dddd      j                  |        y)rd   z--python-venvr   python_venvzThe path to the zip file to manage the virtualenv for Python dependencies. Required if the job type is python. Must start with gs://.r0   NrD   r8   s    r   AddPythonVirtualEnvArgumentr   ^  s(    --	 Kr   )F)NNF)r   F)"r   rk   googlecloudsdk.callioper   r   googlecloudsdk.command_lib.utilr   r   r   ParameterInfoByConventionr
   r   r'   r!   r:   r>   rG   rP   rT   r\   rb   rg   rm   rr   rv   ry   r}   r   r   r   r   r   r   r   r%   r   r   <module>r      s    3  / ( 6 > 4	 1KK $	::: 	.  )+>*FG  
			2
	  	8(	r   