
    %                         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 HTTP health checks.    )absolute_import)division)unicode_literals)base_classes)arg_parsers)base)
exceptions)flags)log
      i,  c                   j    \ rS rSrSrSr\S 5       r\S 5       r	\S 5       r
S rS rS	 rS
 rS rSrg)Update$   zUpdate a legacy HTTP health check.

*{command}* is used to update an existing legacy HTTP 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--hostat          The value of the host header used in this HTTP 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 HTTP 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.  Valid units for this flag are ``s'' for seconds and
        ``m'' for minutes.
        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--descriptionzRA textual description for the HTTP health check. Pass in an empty string to unset.)r
   HttpHealthCheckArgumentHTTP_HEALTH_CHECKS_ARGAddArgumentadd_argumentintr   Duration)clsparsers     0lib/surface/compute/http_health_checks/update.pyArgsUpdate.Args.   s3   !&!>!>!@C**6(*K
         !!#   !!#  
       '  )    c                 .    U R                   R                  $ N)computehttpHealthChecksselfs    r   serviceUpdate.serviceu   s    <<(((r!   c                     g)Nr%    r&   s    r   resource_typeUpdate.resource_typey   s    r!   c                 8    U R                   R                  X!5      $ r#   )r   ResolveAsResource)r'   	resourcesargss      r   CreateReferenceUpdate.CreateReference}   s    &&88 r!   c                     UR                   R                  SUR                  R                  UR	                  5       UR
                  S94$ )z>Returns a request for fetching the existing HTTP health check.Get)httpHealthCheckproject)apitools_clientr%   messages!ComputeHttpHealthChecksGetRequestNamer7   )r'   clienthttp_health_check_refs      r   GetGetRequestUpdate.GetGetRequest   sJ    ""33OO== 5 : : <-55 > 78 8r!   c                     UR                   R                  SUR                  R                  UR	                  5       UUR
                  S94$ )z4Returns a request for updated the HTTP health check.r   )r6   httpHealthCheckResourcer7   )r8   r%   r9   $ComputeHttpHealthChecksUpdateRequestr;   r7   )r'   r<   r=   replacements       r   GetSetRequestUpdate.GetSetRequest   sN    ""33OO@@ 5 : : <(3-55 A 78 8r!   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 HttpHealthCheck message.N)	namehostportdescriptionrequestPathcheckIntervalSec
timeoutSechealthyThresholdunhealthyThreshold)rJ   rH   r9   HttpHealthCheckrG   rI   request_pathrK   check_intervalrL   timeoutrM   healthy_thresholdrN   unhealthy_thresholdrO   )r'   r<   r1   existing_checkrJ   rH   new_health_checks          r   ModifyUpdate.Modify   s   
 $$k				!"..kkyyYYd		  dd66  YY-.--%%C)C)C-- :(99<<<>#<#<00 :(99 44 >*== 7  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+                  UR,                  U5      nU R/                  X55      nUR1                  U/5      nU R3                  X1US   5      nUS   U:X  a=  [4        R6                  R9                  SR                  US   R:                  5      5        U$ UR1                  U R=                  X5U5      /5      $ )Nzh[--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<   rR   CHECK_INTERVAL_LOWER_BOUND_SECCHECK_INTERVAL_UPPER_BOUND_SECr	   ArgumentErrorformatrS   TIMEOUT_LOWER_BOUND_SECTIMEOUT_UPPER_BOUND_SECrT   THRESHOLD_LOWER_BOUNDTHRESHOLD_UPPER_BOUNDrU   rI   rQ   rJ   rH   r2   r0   r>   MakeRequestsrX   r   statusPrintrG   rD   )	r'   r1   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 001A1A4H$$VCK!!;-0GV71:6J
 qzZ	jj
;
B
Bajoo  n			F:	FGI Ir!   r+   )__name__
__module____qualname____firstlineno____doc__r   classmethodr   propertyr(   r,   r2   r>   rD   rX   rm   __static_attributes__r+   r!   r   r   r   $   sh      D) D)L ) )  88!FAIr!   r   N)rs   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   0googlecloudsdk.command_lib.compute.health_checksr	   5googlecloudsdk.command_lib.compute.http_health_checksr
   googlecloudsdk.corer   rd   rc   rb   ra   r^   r]   UpdateCommandr   r+   r!   r   <module>r~      s_    / &  ' 7 / ( G G #    !$ !" RIT RIr!   