
                            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
 Zd Zd Ze	j                    e	j"                  e	j$                  j&                         G d de	j(                                      Zy)z'Command for creating UDP health checks.    )absolute_import)division)unicode_literals)base_classes)health_checks_utils)base)
exceptions)flagsc                      dddS )Nz=Create a UDP health check to monitor load balanced instances.a            *{command}* is used to create a UDP health check. UDP health checks
        monitor instances in a load balancer controlled by a target pool. All
        arguments to the command are optional except for the name of the health
        check, request and response. For more information on load balancing, see
        [](https://cloud.google.com/compute/docs/load-balancing-and-autoscaling/)
          )briefDESCRIPTION r       /lib/surface/compute/health_checks/create/udp.py_DetailedHelpr      s     J	
 r   c                     | j                   j                  t        j                         t        j                  d      j                  | d       t        j                  |        t        j                  | d       y )NUDPcreate)operation_type)	display_info	AddFormatr
   DEFAULT_LIST_FORMATHealthCheckArgumentAddArgumentr   AddUdpRelatedArgsAddProtocolAgnosticCreationArgs)parsers    r   _Argsr   +   sX     9 9:E"..vh.O''/55feDr   c                    |j                   }t        j                  d      j                  | |j                        }| j
                  st        j                  d      | j                  st        j                  d      t        j                  |      r|j                  j                  |j                  j                  |j                         | j                  |j                  j                  j                   j"                  |j                  j%                  | j
                  | j                  | j&                  | j(                        | j*                  | j,                  | j.                  | j0                        |j2                  |j4                        }|j6                  j8                  }n|j                  j;                  |j                  j                  |j                         | j                  |j                  j                  j                   j"                  |j                  j%                  | j
                  | j                  | j&                  | j(                        | j*                  | j,                  | j.                  | j0                        |j2                        }|j6                  j<                  }|j?                  |d|fg      S )	z9Issues the request necessary for adding the health check.r   z)"request" field for UDP can not be empty.z*"response" field for UDP can not be empty.)requestresponseportportName)namedescriptiontypeudpHealthCheckcheckIntervalSec
timeoutSechealthyThresholdunhealthyThreshold)healthCheckprojectregion)r,   r-   Insert) clientr
   r   ResolveAsResource	resourcesr    r	   ArgumentErrorr!   r   IsRegionalHealthCheckRefmessages&ComputeRegionHealthChecksInsertRequestHealthCheckNamer%   TypeValueValuesEnumr   UDPHealthCheckr"   	port_namecheck_intervaltimeouthealthy_thresholdunhealthy_thresholdr-   r.   apitools_clientregionHealthChecks ComputeHealthChecksInsertRequesthealthChecksMakeRequests)argsholderr0   health_check_refr    
collections         r   _RunrI   2   s@   ==&..u5GG
F 


"
"#N
OO	

"
"#O
PP112BCooDDOO//!&&(((,,@@DD!??99YY	 : )
 "00||!33#77 0 
 !((&&! E (G" ''::Joo>>OO//!&&(((,,@@DD!??99YY	 : )
 "00||!33#77 0 
 !(( ? *G  ''44J			z8W=>	??r   c                   4    e Zd ZdZ e       Zed        Zd Zy)CreateAlphaa  Create an Alpha UDP health check to monitor load balanced instances.

  Business logic should be put in helper functions. Classes annotated with
  @base.ReleaseTracks should only be concerned with calling helper functions
  with the correct feature parameters.
  c                     t        |       y N)r   )clsr   s     r   ArgszCreateAlpha.Argst   s	    	&Mr   c                 `    t        j                  | j                               }t        ||      S rM   )r   ComputeApiHolderReleaseTrackrI   )selfrE   rF   s      r   RunzCreateAlpha.Runx   s(    **4+<+<+>?Ffr   N)	__name__
__module____qualname____doc__r   detailed_helpclassmethodrO   rT   r   r   r   rK   rK   h   s'      /- r   rK   N)rX   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   googlecloudsdk.callioper   0googlecloudsdk.command_lib.compute.health_checksr	   r
   r   r   rI   HiddenReleaseTracksrR   ALPHACreateCommandrK   r   r   r   <module>rc      sz    . &  ' 7 > ( G BE3@l D%%++,$$$  - r   