
                         V   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  SSKJr  S r " S S\R,                  5      r\R0                  " \R2                  R4                  5       " S S\R6                  5      5       r\R0                  " \R2                  R:                  5       " S S\5      5       r\R0                  " \R2                  R>                  5       " S S\5      5       r SSSS.\l!        \RB                  \ l!        \RB                  \l!        g)zGCommand to PATCH-style update autoscaling for a managed instance group.    )absolute_import)division)unicode_literals)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.Args1   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_typer3   messagesAutoscalingPolicyIsSpecifiedParseModeStringr5   r4   scaleInControlBuildScaleInclear_scale_downscaleDownControlAutoscalingPolicyCpuUtilizationPredictiveMethodValueValuesEnumcpuUtilizationr   ChoiceToEnumr8   predictiveMethodBuildSchedulesscalingSchedulesr9   minNumReplicasr:   maxNumReplicas_SendPatchRequest)selfargsholderr=   igm_refold_autoscalerautoscalers_clientnew_autoscalerr5   cpu_predictive_enum	scheduleds              r   RunUpdateAutoscaling.Run6   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)Nr6   z autoscalingPolicy.scaleInControlr7   z"autoscalingPolicy.scaleDownControl)rJ   apitools_clientIncludeFieldsPatchrN   )rZ   r[   r=   r_   r]   r`   s         r   rY   #UpdateAutoscaling._SendPatchRequestj   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__rN   staticmethodr0   rc   rY   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)UpdateAutoscalingBetay   r+   Tc                 p    [        U 5        [        R                  " U SS9  [        R                  " U 5        g r-   r   r   r/   AddClearScaleDownControlFlagr   s    r   r0   UpdateAutoscalingBeta.Args   s(    &&v>**62r   r"   N	r#   r$   r%   r&   rj   rN   rk   r0   r'   r"   r   r   rm   rm   y       B3 3r   rm   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 )Nrp   r   s    r   r0   UpdateAutoscalingAlpha.Args   s&    &&v.**62r   r"   Nrs   r"   r   r   rv   rv      rt   r   rv   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)"rj   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r   6googlecloudsdk.api_lib.compute.instance_groups.managedr   rE   googlecloudsdk.callioper	   2googlecloudsdk.command_lib.compute.instance_groupsr
   r   $googlecloudsdk.command_lib.util.apisr   googlecloudsdk.corer   r   Errorr    ReleaseTracksr<   GACommandr)   BETArm   ALPHArv   detailed_helpr"   r   r   <module>r      s   N &  ' 7 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   