
    u$                         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rSrSrSrSrSr " S S\	R,                  5      rg)z)Command for updating HTTPS health checks.    )absolute_import)division)unicode_literals)base_classes)arg_parsers)base)
exceptions)flags)log
      i,  c                   D    \ rS rSrSrSr\S 5       rS rS r	S r
S rS	rg)
Update$   zUpdate a legacy HTTPS health check.

*{command}* is used to update an existing legacy HTTPS health check. Only
arguments passed in will be updated on the health check. Other
attributes will remain unaffected.
Nc                    [         R                  " 5       U l        U R                  R                  USS9  UR	                  SSS9  UR	                  S[
        SS9  UR	                  S	S
S9  UR	                  S[        R                  " 5       SS9  UR	                  S[        R                  " 5       SS9  UR	                  S[
        SS9  UR	                  S[
        SS9  UR	                  SSS9  g )Nupdate)operation_typez--hostau          The value of the host header used in this HTTPS health check request.
        By default, this is empty and Compute Engine automatically sets
        the host header in health requests to the same external IP address as
        the forwarding rule associated with the target pool. Setting this to
        an empty string will clear any existing host value.
        )helpz--portzE        The TCP port number that this health check monitors.
        )typer   z--request-pathzi        The request path that this health check monitors. For example,
        ``/healthcheck''.
        z--check-intervalz        How often to perform a health check for an instance. For example,
        specifying ``10s'' will run the check every 10 seconds.
        See $ gcloud topic datetimes for information on duration formats.
        z	--timeouta          If Compute Engine doesn't receive an HTTPS 200 response from the
        instance by the time specified by the value of this flag, the health
        check request is considered a failure. For example, specifying ``10s''
        will cause the check to wait for 10 seconds before considering the
        request a failure.
        See $ gcloud topic datetimes for information on duration formats.
        z--unhealthy-thresholdzz        The number of consecutive health check failures before a healthy
        instance is marked as unhealthy.
        z--healthy-thresholdz~        The number of consecutive successful health checks before an
        unhealthy instance is marked as healthy.
        z--descriptionzSA textual description for the HTTPS health check. Pass in an empty string to unset.)r
   HttpsHealthCheckArgumentHTTPS_HEALTH_CHECKS_ARGAddArgumentadd_argumentintr   Duration)clsparsers     1lib/surface/compute/https_health_checks/update.pyArgsUpdate.Args.   s3   "'"@"@"BC++F8+L
         !!#   !!#  
       '  )    c                     UR                   R                  SUR                  R                  UR	                  5       UR
                  S94$ )z?Returns a request for fetching the existing HTTPS health check.Get)httpsHealthCheckproject)apitools_clienthttpsHealthChecksmessages"ComputeHttpsHealthChecksGetRequestNamer%   )selfclienthttps_health_check_refs      r   GetGetRequestUpdate.GetGetRequestu   sJ    ""44OO>>!7!<!<!>.66 ? 89 9r!   c                     UR                   R                  SUR                  R                  UR	                  5       UUR
                  S94$ )z5Returns a request for updated the HTTPS health check.r   )r$   httpsHealthCheckResourcer%   )r&   r'   r(   %ComputeHttpsHealthChecksUpdateRequestr*   r%   )r+   r,   r-   replacements       r   GetSetRequestUpdate.GetSetRequest}   sN    ""44OOAA!7!<!<!>)4.66 B 89 9r!   c                    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                  nOSnUR                  R                  UR                  UUR
                  =(       d    UR
                  UUR                  =(       d    UR                  UR                  =(       d    UR                  UR                  =(       d    UR                  UR                  =(       d    UR                  UR                  =(       d    UR                  S9	nU$ )z,Returns a modified HttpsHealthCheck message.N)	namehostportdescriptionrequestPathcheckIntervalSec
timeoutSechealthyThresholdunhealthyThreshold)r:   r8   r(   HttpsHealthCheckr7   r9   request_pathr;   check_intervalr<   timeoutr=   healthy_thresholdr>   unhealthy_thresholdr?   )r+   r,   argsexisting_checkr:   r8   new_health_checks          r   ModifyUpdate.Modify   s   
 $$k				!"..kkyyYYd		  dd77  YY-.--%%C)C)C-- :(99<<<>#<#<00 :(99 44 >*== 8  r!   c                    [         R                  " U R                  5       5      nUR                  nUR                  ba  UR                  [
        :  d  UR                  [        :  a9  [        R                  " SR                  [
        [        UR                  5      5      eUR                  ba  UR                  [        :  d  UR                  [        :  a9  [        R                  " SR                  [        [        UR                  5      5      eUR                  ba  UR                  [        :  d  UR                  [        :  a9  [        R                  " SR                  [        [        UR                  5      5      eUR                   ba  UR                   [        :  d  UR                   [        :  a9  [        R                  " SR                  [        [        UR                   5      5      eUR"                  =(       dX    UR$                  =(       dE    UR                  =(       d2    UR                  =(       d    UR                  =(       d    UR                   (       + nUR&                  c*  UR(                  c  U(       a  [        R                  " S5      eU R*                  R-                  XR.                  5      nU R1                  X55      nUR3                  U/5      nU R5                  X1US   5      nUS   U:X  a=  [6        R8                  R;                  SR                  US   R<                  5      5        U$ UR3                  U R?                  X5U5      /5      $ )z<Issues requests necessary to update the HTTPS Health Checks.zh[--check-interval] must not be less than {0} second or greater than {1} seconds; received [{2}] seconds.zb[--timeout] must not be less than {0} second or greater than {1} seconds; received: [{2}] seconds.zY[--healthy-threshold] must be an integer between {0} and {1}, inclusive; received: [{2}].zZ[--unhealthy-threshold] must be an integer between {0} and {1}, inclusive; received [{2}].z'At least one property must be modified.r   z/No change requested; skipping update for [{0}].) r   ComputeApiHolderReleaseTrackr,   rB   CHECK_INTERVAL_LOWER_BOUND_SECCHECK_INTERVAL_UPPER_BOUND_SECr	   ArgumentErrorformatrC   TIMEOUT_LOWER_BOUND_SECTIMEOUT_UPPER_BOUND_SECrD   THRESHOLD_LOWER_BOUNDTHRESHOLD_UPPER_BOUNDrE   r9   rA   r:   r8   r   ResolveAsResource	resourcesr.   MakeRequestsrI   r   statusPrintr7   r4   )	r+   rF   holderr,   
args_unsetr-   get_requestobjects
new_objects	            r   Run
Update.Run   s   **4+<+<+>?F]]F'  #AA##&DD$$66<f,.L!!7#$ $ 	 \\3366$$..4f%'>/NO O
 	*##&;;&&)>>$$((./D/D/3/E/E)GH H 	  ,%%(==((+@@$$''-v.C.C.2.F.F(HI I ii 2**2,,2 2 //	2
 113J DII$5*$$%NOO!99KK $$VDK!!;-0GV71:6J
 qzZ	jj
;
B
Bajoo  n			FJ	GHJ Jr!    )__name__
__module____qualname____firstlineno____doc__r   classmethodr   r.   r4   rI   r`   __static_attributes__rb   r!   r   r   r   $   s;     !D) D)L99!FCJr!   r   N)rg   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   0googlecloudsdk.command_lib.compute.health_checksr	   6googlecloudsdk.command_lib.compute.https_health_checksr
   googlecloudsdk.corer   rU   rT   rS   rR   rO   rN   UpdateCommandr   rb   r!   r   <module>rq      s_    0 &  ' 7 / ( G H #    !$ !" HJT HJr!   