
     '                        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SKJr  S rS rS rS rS rS rS r SS jrS r\	R8                  " \	R:                  R<                  5       " S S\	R>                  5      5       r \	R8                  " \	R:                  RB                  5       " S S\ 5      5       r"\	R8                  " \	R:                  RF                  5       " S S\"5      5       r$g)z#Command for updating health checks.    )absolute_import)division)unicode_literals)base_classes)health_checks_utils)base)scope)
exceptions)flags)logc                      SSSS.$ )NUpdate a HTTP2 health check.z      *{command}* is used to update an existing HTTP2 health check. Only
      arguments passed in will be updated on the health check. Other
      attributes will remain unaffected.
      z          To update health check interval to 10s, run:

            $ {command} my-health-check-name --check-interval=10s
      )briefDESCRIPTIONEXAMPLES r       1lib/surface/compute/health_checks/update/http2.py_DetailedHelpr      s     )


 r   c                    [         R                  " S5      nUR                  U SS9  [        R                  " U U5        [        R
                  " U 5        [        R                  " U S5        U(       a  [        R                  " U 5        gg)z Adds all the args in the parser.HTTP2update)operation_typeN)r   HealthCheckArgumentAddArgumentr   AddHttpRelatedUpdateArgsAddHttpRelatedResponseArgAddProtocolAgnosticUpdateArgs AddHealthCheckLoggingRelatedArgs)parserinclude_log_configinclude_weighted_load_balancinghealth_check_args       r   _Argsr$   2   sn    ..w7vh?..v/NP//733FGD88@ r   c                     U R                   R                  SU R                  R                  UR	                  5       UR
                  S94$ )9Returns a request for fetching the existing health check.Get)healthCheckproject)apitools_clienthealthChecksmessagesComputeHealthChecksGetRequestNamer)   clienthealth_check_refs     r   _GetGetRequestr2   >   sI    

 
 
-
-u
//
7
7*//1&.. 8 0
1 1r   c                     U R                   R                  SU R                  R                  UR	                  5       UUR
                  S94$ )0Returns a request for updating the health check.Update)r(   healthCheckResourcer)   )r*   r+   r,    ComputeHealthChecksUpdateRequestr.   r)   r0   r1   replacements      r   _GetSetRequestr:   F   sL    

 
 
-
-x
//
:
:*//1"-&.. ; 0
1 1r   c                     U R                   R                  SU R                  R                  UR	                  5       UR
                  UR                  S94$ )r&   r'   )r(   r)   region)r*   regionHealthChecksr,   #ComputeRegionHealthChecksGetRequestr.   r)   r<   r/   s     r   _GetRegionalGetRequestr?   O   sR    

 
 
3
3U
//
=
=*//1&..%,, > .
/ /r   c           	          U R                   R                  SU R                  R                  UR	                  5       UUR
                  UR                  S94$ )r4   r5   )r(   r6   r)   r<   )r*   r=   r,   &ComputeRegionHealthChecksUpdateRequestr.   r)   r<   r8   s      r   _GetRegionalSetRequestrB   X   sV    

 
 
3
3X
//
@
@*//1"-&..%,,	 A .
/ /r   c                    UR                   U R                  R                  R                  R                  :w  a-  [
        R                  " SUR                   R                  -   5      eUR                  (       a  UR                  nOUR                  c  UR                  nOSnUR                  (       a  UR                  nO&UR                  c  UR                  R                  nOSnUR                  (       a  UR                  nO&UR                  c  UR                  R                  nOSn[        R                  " XR                  5      u  pn
U(       a[  UR                  R                  nUR                  S5      (       a/  U R                  R                   R#                  UR$                  5      nUR                  R&                  nUR(                  b/  U R                  R                   R+                  UR(                  5      nU R                  R!                  UUU	U
UR,                  =(       d    UR                  R.                  UUS9nU(       a  WUl        U R                  R                  UR                  UU R                  R                  R                  R                  UUR0                  =(       d    UR2                  UR4                  =(       d    UR6                  UR8                  =(       d    UR:                  UR<                  =(       d    UR>                  S9nU(       a&  [        R@                  " XURB                  5      Ul!        U$ )z'Returns a modified HealthCheck message.z>update http2 subcommand applied to health check with protocol Nweight_report_mode)hostportportNameportSpecificationrequestPathproxyHeaderresponse)namedescriptiontypehttp2HealthCheckcheckIntervalSec
timeoutSechealthyThresholdunhealthyThreshold)"rN   r,   HealthCheckTypeValueValuesEnumr   core_exceptionsErrorrL   rM   rE   rO   rK   r   HandlePortRelatedFlagsForUpdateweightReportModeIsSpecifiedHTTP2HealthCheckWeightReportModeValueValuesEnumrD   rJ   proxy_headerProxyHeaderValueValuesEnumrequest_pathrI   check_intervalrP   timeoutrQ   healthy_thresholdrR   unhealthy_thresholdrS   ModifyLogConfig	logConfig)r0   argsexisting_checkr!   r"   rM   rE   rK   rF   	port_nameport_specificationrD   r]   http2_health_checknew_health_checks                  r   _Modifyrl   b   s   
 oo!!55;;<


H  	!" " 
""K ,,KK	YY99Dyy**//DD	]]}}H}}..77HH(;%%)&&*,K,K)M%$% %'88II,--!??;;[[

!
!#  00<<,	"((CC	  77*$$ ?!22>> 8  %*<'__00??&&::@@)++N~/N/N:!:!:.. 8&7722 <(;; 1  !4!D!Dn.."0	r   c                    [         R                  " U 5        U R                  =(       d~    U R                  =(       dk    U R                  =(       dX    U R
                  =(       dE    U R                  =(       d2    U R                  =(       d    U R                  =(       d    U R                  (       + nU(       a  U R                  SL =(       a    UnSnU(       a  U R                  S5      (       a  SnU R                  cP  U R                  cB  U R                  c4  U R                  c&  U(       d  U(       a  [         R"                  " S5      egggggg)zBValidates given args and raises exception if any args are invalid.NFrD   Tz'At least one property must be modified.)r   CheckProtocolAgnosticArgsrF   r_   r`   ra   rb   rc   r]   use_serving_portenable_loggingrZ   rM   rE   rK   rh   r
   ArgumentError)rf   r!   r"   
args_unsetweight_report_mode_modifieds        r   _ValidateArgsrt      s    //5II *!2!2 *d6I6I *LL*$($:$:*,,*040A0A* ))+*
 %%-<*J %$)9)9:N)O)O"&
499#4
mm 6
%*

"
"#L
MM +5
% !7 $5r   c                    UR                   n[        XU5        [        R                  " S5      nUR	                  XR
                  [        R                  R                  S9n[        R                  " U5      (       a  [        XF5      nO[        XF5      nUR                  U/5      n[        X@US   UU5      n	US   U	:X  a=  [        R                   R#                  SR%                  US   R&                  5      5        U$ [        R                  " U5      (       a  [)        XFU	5      n
O[+        XFU	5      n
UR                  U
/5      $ )z<Issues requests necessary to update the HTTP2 Health Checks.r   )default_scoper   z/No change requested; skipping update for [{0}].)r0   rt   r   r   ResolveAsResource	resourcescompute_scope	ScopeEnumGLOBALr   IsRegionalHealthCheckRefr?   r2   MakeRequestsrl   r   statusPrintformatrL   rB   r:   )rf   holderr!   r"   r0   r#   r1   get_requestobjects
new_objectset_requests              r   _Runr      s    ==&*IJ..w7%77
M,C,C,J,J 8 L112BCC(BK :K.'vWQZ1C68* QZ:JJFMM
 N112BCC(:NK :FK			k]	++r   c                   D    \ rS rSrSrSrSr\" 5       r\	S 5       r
S rSrg)	r5      r   TFc                 D    [        XR                  U R                  5        g N)r$   _include_log_config _include_weighted_load_balancing)clsr    s     r   ArgsUpdate.Args   s    	&))3+O+OPr   c                     [         R                  " U R                  5       5      n[        XU R                  U R
                  5      $ r   )r   ComputeApiHolderReleaseTrackr   r   r   )selfrf   r   s      r   Run
Update.Run   s;    **4+<+<+>?Fd66557 7r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   r   detailed_helpclassmethodr   r   __static_attributes__r   r   r   r5   r5      s1    $%*"/-Q Q7r   r5   c                       \ rS rSrSrSrg)
UpdateBetai  Fr   Nr   r   r   r   r   r   r   r   r   r   r     s
     &+"r   r   c                       \ rS rSrSrSrg)UpdateAlphai  Tr   Nr   r   r   r   r   r     s
     &*"r   r   N)F)%r   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   ry   0googlecloudsdk.command_lib.compute.health_checksr
   r   googlecloudsdk.corerV   r   r   r$   r2   r:   r?   rB   rl   rt   r   ReleaseTracksr   GAUpdateCommandr5   BETAr   ALPHAr   r   r   r   <module>r      s    * &  ' 7 > ( E G B = #&	A11//Oh 38N0 ,F D%%(()7T 7 *7" D%%**++ + ,+
 D%%++,** * -*r   