
                         2   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dlmZ ddlmZ ej*                   ej,                  ej.                  j0                         G d dej2                                      Zy)z!Update a Flink job's parallelism.    )absolute_import)division)unicode_literals)util)waiter)base)flags)flink_backend)common_args)log)
properties)	resourcesc                   &    e Zd ZdZed        Zd Zy)Updatea  Update the parallelism of a Flink job.

  Update the parallelism of a Flink job.

  ## EXAMPLES

  The following command updates a Flink Job with the ID `example-job-id`
  to change max parallesim to 4:

    $ {command} example-job-id \
        --project=example-project \
        --location=us-central1 \
        --autotuning-mode elastic \
        --min-parallelism=1 \
        --max-parallelism=4 \

  c                    t        j                  d      j                  |        t        j                  |        t        j
                  |        t        j                  | d       t        j                  |        t        j                  | d       t        j                  |        t        j                  |        t        j                  | d       y )NzProject to update the job in.)help_text_to_overwritez Deployment to update the job in.Frequired)default)r   ProjectArgumentAddToParserr	   AddJobIdArgumentAddLocationArgumentAddDeploymentArgumentAddShowOutputArgumentAddAutotuningModeArgumentAddFixedParallelismArgsAddElasticParallelismArgsAddAsyncArgument)parsers    (lib/surface/managed_flink/jobs/update.pyArgszUpdate.Args6   s    >k&	6"	f%	'I 
'	##FU;	!!&)	##F+	651    c                    t        j                  |j                  |j                  |j                  |j
                         t        j                  | j                               }|j                         }|j                  dk(  r"|j                  |j
                        |_        n7|j                  |j                  |j                  |j                        |_        |j                  |      }|j                  |j                   |      }|j"                  r|j"                  |_        |j'                  dj)                  t*        j,                  j.                  j0                  j3                  d      |j4                  |j                         |d	
      }t        j6                  | j                               }|j8                  j:                  j=                  |      }|j>                  r|S t@        jB                  jE                  dj)                  |jF                  jH                               tJ        jL                  jO                  |jH                  d      }	tQ        jR                  tQ        jT                  |j8                  j:                  |j8                  jV                        |	dj)                  |jH                               |S )Nfixed)parallelism)r&   minParallelismmaxParallelism)autotuningConfig)namejobSpecz#projects/{0}/locations/{1}/jobs/{2}Tr   r)   )r*   job
updateMaskzUpdate request issued for [{0}]z*managedflink.projects.locations.operations)
collectionz2Waiting for update operations [{0}] to complete...),r
   ValidateAutotuningautotuning_modemin_parallelismmax_parallelismr&   
flink_utilGetMessagesModuleReleaseTrackAutotuningConfigFixedr%   ElasticthroughputBasedJobSpecJobjob_id
deploymentdeploymentId-ManagedflinkProjectsLocationsJobsPatchRequestformatr   VALUEScoreprojectGetlocationFlinkClientclientprojects_locations_jobsPatchasync_submitr   statusPrintr,   r*   r   REGISTRYParser   WaitForCloudOperationPollerprojects_locations_operations)
selfargsmsgautotuning_configjobspecr,   updateflink_clientpatch_oppatch_op_refs
             r!   Runz
Update.RunF   sM   $$	 
&
&t'8'8':
;C ,,.w& #		d6F6F	 G*-++**---- +6 +' kk*  G ''[[  C
 c>>299""**...=MMKK

 % ? F ))$*;*;*=>L""::@@HHoJJ6==fjjooNO%%++"N , L NN##77==	
 	<CCMM	
	 Or#   N)__name__
__module____qualname____doc__staticmethodr"   r[    r#   r!   r   r   !   s     $ 2 2?r#   r   N)r_   
__future__r   r   r   $googlecloudsdk.api_lib.managed_flinkr   r3   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   (googlecloudsdk.command_lib.managed_flinkr	   r
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r   DefaultUniverseOnlyReleaseTracksr5   ALPHAUpdateCommandr   ra   r#   r!   <module>rm      sy     ( &  ' C . ( : B < # * ) D%%++,bT b - br#   