
    (                     2   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	 r " S
 S\R$                  5      r\	R(                  " \	R*                  R,                  5       " S S\	R.                  5      5       r\	R(                  " \	R*                  R2                  5       " S S\5      5       r\	R(                  " \	R*                  R6                  5       " S S\5      5       rSSSS.\l        \R:                  \l        \R:                  \l        g)zGCommand to PATCH-style update autoscaling for a managed instance group.    )base_classes)managed_instance_groups_utils)autoscalers)base)flags)	arg_utils)
exceptionsc                    [         R                  R                  U 5        [        R                  " 5       R                  U 5        [        R                  " U SS9  [        R                  " U SS9  [        R                  " U SS9  g )NT)include_clearF)max_required)
patch_args)	instance_groups_flags%MULTISCOPE_INSTANCE_GROUP_MANAGER_ARGAddArgument	mig_utilsGetModeFlagAddToParserAddScaleInControlFlagAddMinMaxControlAddScheduledAutoscalingparsers    Alib/surface/compute/instance_groups/managed/update_autoscaling.py_CommonArgsr      s`    ==II%%f-!!&=V%8##Ft<    c                       \ rS rSrSrg)NoMatchingAutoscalerFoundError$    N)__name__
__module____qualname____firstlineno____static_attributes__r   r   r   r   r   $   s    r   r   c                   8    \ rS rSrSrSr\S 5       rS rS r	Sr
g)	UpdateAutoscaling(   :Update autoscaling parameters of a managed instance group.Fc                 D    [        U 5        [        R                  " U SS9  g NF)standard)r   r   AddPredictiveAutoscalingr   s    r   ArgsUpdateAutoscaling.Args.   s    &&v>r   c                 r   [         R                  " U R                  5       5      nUR                  n[        R
                  " X2R                  U5      n[        R                  " XC5        [        R                  " X2R                  U5      n[        R                  " U5      (       a(  [        SR                  UR                  5       5      5      e[        R                  " X45      nUR!                  UR"                  UR$                  R'                  5       S9nUR)                  S5      (       a;  [        R*                  " UR,                  UR$                  5      nXR.                  l        UR)                  S5      (       a  S UR.                  l        O/[        R2                  " XR$                  5      UR.                  l        U R4                  (       a'  UR)                  S5      (       a  S UR.                  l        UR)                  S5      (       a  UR$                  R8                  R:                  n	UR$                  R9                  5       UR.                  l        [>        R@                  " URB                  U	5      UR.                  R<                  l"        [        RF                  " XR$                  5      n
U
(       a  XR.                  l$        UR)                  S5      (       a  URJ                  UR.                  l&        UR)                  S5      (       a  URN                  UR.                  l(        U RS                  XXdU5      $ )	NzFInstance group manager [{}] has no existing autoscaler; cannot update.)nameautoscalingPolicymodeclear_scale_in_controlclear_scale_down_control!cpu_utilization_predictive_methodmin_num_replicasmax_num_replicas)*r   ComputeApiHolderReleaseTrackclientr   CreateGroupReference	resourcesr   GetInstanceGroupManagerOrThrowAutoscalerForMigByRefIsAutoscalerNewr   formatNameautoscalers_api	GetClientmessage_typer0   messagesAutoscalingPolicyIsSpecifiedParseModeStringr2   r1   scaleInControlBuildScaleInclear_scale_downscaleDownControlAutoscalingPolicyCpuUtilizationPredictiveMethodValueValuesEnumcpuUtilizationr   ChoiceToEnumr5   predictiveMethodBuildSchedulesscalingSchedulesr6   minNumReplicasr7   maxNumReplicas_SendPatchRequest)selfargsholderr:   igm_refold_autoscalerautoscalers_clientnew_autoscalerr2   cpu_predictive_enum	scheduleds              r   RunUpdateAutoscaling.Run3   s   **4+<+<+>?F]]F#88  $(G ,,W=44V=M=M5<>N  00*!6',,.13 3 )226C'44   //;;= 5 ?N &&tyy&//Bd.2&&+0118<n&&5 	t__5 &&5 !1!12L!M!M:>n&&7;<<"OOKKkk8>8g8g 9n&&5IRI_I_

0
02EJGn&&55F ((?I:C&&7*++8<8M8Mn&&5*++8<8M8Mn&&5!!$0B"02 2r   c                    UR                  S5      (       a7  UR                  R                  S/5         UR                  XE5      sS S S 5        $ U R                  (       aM  UR                  S5      (       a7  UR                  R                  S/5         UR                  XE5      sS S S 5        $ UR                  XE5      $ ! , (       d  f       g = f! , (       d  f       g = f)Nr3   z autoscalingPolicy.scaleInControlr4   z"autoscalingPolicy.scaleDownControl)rG   apitools_clientIncludeFieldsPatchrK   )rW   rX   r:   r\   rZ   r]   s         r   rV   #UpdateAutoscaling._SendPatchRequestg   s    011!!//-
.0!''@0 0 
		4#3#34N#O#O!!///
02!''@2 2  %%g>>0 02 2s   B=C=
C
Cr   N)r    r!   r"   r#   __doc__rK   staticmethodr-   r`   rV   r$   r   r   r   r&   r&   (   s(    B? ?22h?r   r&   c                   ,    \ rS rSrSrSr\S 5       rSrg)UpdateAutoscalingBetav   r(   Tc                 p    [        U 5        [        R                  " U SS9  [        R                  " U 5        g r*   r   r   r,   AddClearScaleDownControlFlagr   s    r   r-   UpdateAutoscalingBeta.Args|   s(    &&v>**62r   r   N	r    r!   r"   r#   rg   rK   rh   r-   r$   r   r   r   rj   rj   v       B3 3r   rj   c                   ,    \ rS rSrSrSr\S 5       rSrg)UpdateAutoscalingAlpha   r(   Tc                 r    [        U 5        [        R                  " U 5        [        R                  " U 5        g )Nrm   r   s    r   r-   UpdateAutoscalingAlpha.Args   s&    &&v.**62r   r   Nrp   r   r   r   rs   rs      rq   r   rs   z9Update autoscaling parameters of a managed instance groupzf        To update an existing instance group:

            $ {command} --mode=only-scale-out

        a  
*{command}* updates autoscaling parameters of specified managed instance
group.

Autoscalers can use one or more autoscaling signals. Information on using
multiple autoscaling signals can be found here: [](https://cloud.google.com/compute/docs/autoscaler/multiple-signals)

In contrast to *{parent_command} set-autoscaling*, this command *only* updates
specified fields. For instance:

    $ {command} --mode only-scale-out

would change the *mode* field of the autoscaler policy, but leave the rest of
the settings intact.
        )briefEXAMPLESDESCRIPTIONN)rg   googlecloudsdk.api_lib.computer   r   r   6googlecloudsdk.api_lib.compute.instance_groups.managedr   rB   googlecloudsdk.callioper   2googlecloudsdk.command_lib.compute.instance_groupsr   r   $googlecloudsdk.command_lib.util.apisr   googlecloudsdk.corer	   r   Errorr   ReleaseTracksr9   GACommandr&   BETArj   ALPHArs   detailed_helpr   r   r   <module>r      s   N 8 U a ( ] : *=Z%5%5  D%%(()J? J? *J?Z D%%**+	3- 	3 ,	3 D%%++,	32 	3 -	3 I	#  2 (9'F'F  $&7&E&E  #r   