U
    W¨+dÀ  ã                   @   s   d Z G dd„ deƒZdS )a(  
From http://docs.aws.amazon.com/Route53/latest/APIReference/API_CreateHealthCheck.html

POST /2013-04-01/healthcheck HTTP/1.1

<?xml version="1.0" encoding="UTF-8"?>
<CreateHealthCheckRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
   <CallerReference>unique description</CallerReference>
   <HealthCheckConfig>
      <IPAddress>IP address of the endpoint to check</IPAddress>
      <Port>port on the endpoint to check</Port>
      <Type>HTTP | HTTPS | HTTP_STR_MATCH | HTTPS_STR_MATCH | TCP</Type>
      <ResourcePath>path of the file that
         you want Amazon Route 53 to request</ResourcePath>
      <FullyQualifiedDomainName>domain name of the
         endpoint to check</FullyQualifiedDomainName>
      <SearchString>if Type is HTTP_STR_MATCH or HTTPS_STR_MATCH,
         the string to search for in the response body
         from the specified resource</SearchString>
      <RequestInterval>10 | 30</RequestInterval>
      <FailureThreshold>integer between 1 and 10</FailureThreshold>
   </HealthCheckConfig>
</CreateHealthCheckRequest>
c                   @   s:   e Zd ZdZdZdZdZdZdZdZ	ddd„Z
dd„ ZdS )ÚHealthCheckzAn individual health checka~  
        <HealthCheckConfig>
            %(ip_addr_part)s
            <Port>%(port)s</Port>
            <Type>%(type)s</Type>
            <ResourcePath>%(resource_path)s</ResourcePath>
            %(fqdn_part)s
            %(string_match_part)s
            %(request_interval)s
            <FailureThreshold>%(failure_threshold)s</FailureThreshold>
        </HealthCheckConfig>
    z"<IPAddress>%(ip_addr)s</IPAddress>z=<FullyQualifiedDomainName>%(fqdn)s</FullyQualifiedDomainName>z-<SearchString>%(string_match)s</SearchString>z7<RequestInterval>%(request_interval)d</RequestInterval>)é
   é   Nr   é   c	           	      C   sv   || _ || _|| _|| _|| _|| _|| _|| jkr<|| _nt	dd 
dd„ | jD ƒ¡ ƒ‚|dk sj|dkrrt	dƒ‚dS )	aP  
        HealthCheck object

        :type ip_addr: str
        :param ip_addr: Optional IP Address

        :type port: int
        :param port: Port to check

        :type hc_type: str
        :param hc_type: One of HTTP | HTTPS | HTTP_STR_MATCH | HTTPS_STR_MATCH | TCP

        :type resource_path: str
        :param resource_path: Path to check

        :type fqdn: str
        :param fqdn: domain name of the endpoint to check

        :type string_match: str
        :param string_match: if hc_type is HTTP_STR_MATCH or HTTPS_STR_MATCH, the string to search for in the response body from the specified resource

        :type request_interval: int
        :param request_interval: The number of seconds between the time that Amazon Route 53 gets a response from your endpoint and the time that it sends the next health-check request.

        :type failure_threshold: int
        :param failure_threshold: The number of consecutive health checks that an endpoint must pass or fail for Amazon Route 53 to change the current status of the endpoint from unhealthy to healthy or vice versa.

        z)Valid values for request_interval are: %sú,c                 s   s   | ]}t |ƒV  qd S )N)Ústr)Ú.0Úi© r	   ú</tmp/pip-unpacked-wheel-dlxw5sjy/boto/route53/healthcheck.pyÚ	<genexpr>w   s     z'HealthCheck.__init__.<locals>.<genexpr>é   r   z.Valid values for failure_threshold are 1 - 10.N)Úip_addrÚportÚhc_typeÚresource_pathÚfqdnÚstring_matchÚfailure_thresholdÚvalid_request_intervalsÚrequest_intervalÚAttributeErrorÚjoin)	Úselfr   r   r   r   r   r   r   r   r	   r	   r
   Ú__init__M   s$    
ÿÿÿzHealthCheck.__init__c              	   C   sŠ   d| j | j| jdd| jd| ji | jdœ}| jd k	rH| jd| ji |d< | jrb| j	d| ji |d< | j
d k	r€| jd| j
i |d	< | j| S )
NÚ r   )Úip_addr_partr   Útyper   Ú	fqdn_partÚstring_match_partr   r   r   r   r   r   r   r   )r   r   r   ÚXMLRequestIntervalPartr   r   r   ÚXMLFQDNPartr   ÚXMLIpAddrPartr   ÚXMLStringMatchPartÚPOSTXMLBody)r   Úparamsr	   r	   r
   Úto_xml}   s$    ÿ÷

zHealthCheck.to_xml)NNr   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r#   r!   r    r"   r   r   r   r%   r	   r	   r	   r
   r   2   s   
0r   N)r)   Úobjectr   r	   r	   r	   r
   Ú<module>   s   