
                            d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	l
mZ dd
lmZ d Zd Zd Z e	j&                  e	j(                  j*                         G d de	j,                               Z e	j&                  e	j(                  j0                         G d de             Z e	j&                  e	j(                  j4                         G d de             Zy)z)Command for creating HTTP2 health checks.    )absolute_import)division)unicode_literals)base_classes)health_checks_utils)base)
completers)scope)flagsc                      ddddS )Nz>Create a HTTP2 health check to monitor load balanced instancesax            *{command}* is used to create a non-legacy health check using the
          HTTP/2 protocol. You can use this health check for Google Cloud
          load balancers or for managed instance group autohealing.
          For more information, see the health checks overview at:
          [](https://cloud.google.com/load-balancing/docs/health-check-concepts)
          z|          To create a HTTP2 health check with default options, run:

            $ {command} my-health-check-name
          )briefDESCRIPTIONEXAMPLES r       1lib/surface/compute/health_checks/create/http2.py_DetailedHelpr      s     K
 r   c                    | j                   j                  t        j                         t        j                  d      j                  | d       t        j                  | |       t        j                  |        t        j                  | d       |rt        j                  |        | j                   j                  t        j                         y)z0Set up arguments to create an HTTP2 HealthCheck.HTTP2create)operation_typeN)display_info	AddFormatr   DEFAULT_LIST_FORMATHealthCheckArgumentAddArgumentr   AddHttpRelatedCreationArgsAddHttpRelatedResponseArgAddProtocolAgnosticCreationArgs AddHealthCheckLoggingRelatedArgsAddCacheUpdaterr	   HealthChecksCompleterAlpha)parserinclude_log_configinclude_weighted_load_balancings      r   _Argsr&   2   s     9 9:G$00X 1 '00-///755fgF88@%%j&K&KLr   c                    |j                   }|j                  }t        j                  d      j	                  | |j
                  t        j                  j                        }|j                  j                  | j                        }|j                  | j                  | j                  | j                  | j                  || j                         }|r8| j"                  r,|j                  j%                  | j"                        }	|	|_        t)        j*                  | |       t)        j,                  |      r|j/                  |j1                  |j3                         | j4                  |j0                  j6                  j8                  || j:                  | j<                  | j>                  | j@                        |jB                  |jD                        }
|jF                  jH                  }n|jK                  |j1                  |j3                         | j4                  |j0                  j6                  j8                  || j:                  | j<                  | j>                  | j@                        |jB                        }
|jF                  jL                  }|r%t)        jN                  ||       |
jP                  _)        |jU                  |d|
fg      S )z9Issues the request necessary for adding the health check.r   )default_scope)hostportportNamerequestPathproxyHeaderresponse)namedescriptiontypehttp2HealthCheckcheckIntervalSec
timeoutSechealthyThresholdunhealthyThreshold)healthCheckprojectregion)r7   r8   Insert)+clientmessagesr   r   ResolveAsResource	resourcescompute_scope	ScopeEnumGLOBALHTTP2HealthCheckProxyHeaderValueValuesEnumproxy_headerr)   r*   	port_namerequest_pathr.   weight_report_modeWeightReportModeValueValuesEnumweightReportModer   ,ValidateAndAddPortSpecificationToHealthCheckIsRegionalHealthCheckRef&ComputeRegionHealthChecksInsertRequestHealthCheckNamer0   TypeValueValuesEnumr   check_intervaltimeouthealthy_thresholdunhealthy_thresholdr8   r9   apitools_clientregionHealthChecks ComputeHealthChecksInsertRequesthealthChecksCreateLogConfigr7   	logConfigMakeRequests)argsholderr$   r%   r;   r<   health_check_refrD   http2_health_checkrG   request
collections               r   _Runra   @   s{   ==&__(..w7II
FM,C,C,J,J J L**EE
,  009999~~##}} 1  %)@)@!22RR!*<'BB
  112BC==((!&&(((%%99??/!00||!33#77 ) 	
 !((&& > (G ''::J77((!&&(((%%99??/!00||!33#77 ) 9 !(( 8 
*G ''44J$7$G$G%G! 
		z8W=>	??r   c                   <    e Zd ZdZdZdZ e       Zed        Z	d Z
y)CreatezCreate a HTTP2 health check.TFc                 F    t        || j                  | j                         y N)r&   _include_log_config _include_weighted_load_balancing)clsr#   s     r   ArgszCreate.Args   s    	&#))3+O+OPr   c                     t        j                  | j                               }t        ||| j                  | j
                        S re   )r   ComputeApiHolderReleaseTrackra   rf   rg   )selfr[   r\   s      r   Runz
Create.Run   s=    **4+<+<+>?Ffd66557 7r   N)__name__
__module____qualname____doc__rf   rg   r   detailed_helpclassmethodri   rn   r   r   r   rc   rc   ~   s1    $%*"/-Q Q7r   rc   c                       e Zd ZdZy)
CreateBetaFNro   rp   rq   rg   r   r   r   rv   rv      s
     &+"r   rv   c                       e Zd ZdZy)CreateAlphaTNrw   r   r   r   ry   ry      s
     &*"r   ry   N)rr   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r
   r?   0googlecloudsdk.command_lib.compute.health_checksr   r   r&   ra   ReleaseTracksrl   GACreateCommandrc   BETArv   ALPHAry   r   r   r   <module>r      s    0 &  ' 7 > ( 9 E B*M;@| D%%(()7T 7 *7" D%%**++ + ,+
 D%%++,** * -*r   