U
    W¨+d¬  ã                   @   s8   d dl mZ dd„ ZG dd„ deƒZG dd„ deƒZdS )	é    )ÚOriginAccessIdentityc                 C   s   t | tƒr|  ¡ S | S d S ©N)Ú
isinstancer   Úuri)Úorigin_access_identity© r   ú:/tmp/pip-unpacked-wheel-dlxw5sjy/boto/cloudfront/origin.pyÚget_oai_value   s    
r	   c                   @   s:   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚS3Originzž
    Origin information to associate with the distribution.
    If your distribution will use an Amazon S3 origin,
    then you use the S3Origin element.
    Nc                 C   s   || _ || _dS )a  
        :param dns_name: The DNS name of your Amazon S3 bucket to
                         associate with the distribution.
                         For example: mybucket.s3.amazonaws.com.
        :type dns_name: str
        
        :param origin_access_identity: The CloudFront origin access
                                       identity to associate with the
                                       distribution. If you want the
                                       distribution to serve private content,
                                       include this element; if you want the
                                       distribution to serve public content,
                                       remove this element.
        :type origin_access_identity: str
        
        N)Údns_namer   )Úselfr   r   r   r   r   Ú__init__&   s    zS3Origin.__init__c                 C   s
   d| j  S )Nz<S3Origin: %s>©r   ©r   r   r   r   Ú__repr__:   s    zS3Origin.__repr__c                 C   s   d S r   r   ©r   ÚnameÚattrsÚ
connectionr   r   r   ÚstartElement=   s    zS3Origin.startElementc                 C   s0   |dkr|| _ n|dkr || _nt| ||ƒ d S )NÚDNSNamer   )r   r   Úsetattr©r   r   Úvaluer   r   r   r   Ú
endElement@   s
    zS3Origin.endElementc                 C   s:   d}|d| j  7 }| jr.t| jƒ}|d| 7 }|d7 }|S )Nz  <S3Origin>
ú    <DNSName>%s</DNSName>
z4    <OriginAccessIdentity>%s</OriginAccessIdentity>
z  </S3Origin>
)r   r   r	   )r   ÚsÚvalr   r   r   Úto_xmlH   s    
zS3Origin.to_xml)NN©	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r
      s   
r
   c                   @   s:   e Zd ZdZddd„Zdd„ Zd	d
„ Zdd„ Zdd„ ZdS )ÚCustomOriginz¥
    Origin information to associate with the distribution.
    If your distribution will use a non-Amazon S3 origin,
    then you use the CustomOrigin element.
    NéP   é»  c                 C   s   || _ || _|| _|| _dS )a8  
        :param dns_name: The DNS name of your Amazon S3 bucket to
                         associate with the distribution.
                         For example: mybucket.s3.amazonaws.com.
        :type dns_name: str
        
        :param http_port: The HTTP port the custom origin listens on.
        :type http_port: int
        
        :param https_port: The HTTPS port the custom origin listens on.
        :type http_port: int
        
        :param origin_protocol_policy: The origin protocol policy to
                                       apply to your origin. If you
                                       specify http-only, CloudFront
                                       will use HTTP only to access the origin.
                                       If you specify match-viewer, CloudFront
                                       will fetch from your origin using HTTP
                                       or HTTPS, based on the protocol of the
                                       viewer request.
        :type origin_protocol_policy: str
        
        N©r   Ú	http_portÚ
https_portÚorigin_protocol_policy)r   r   r(   r)   r*   r   r   r   r   X   s    zCustomOrigin.__init__c                 C   s
   d| j  S )Nz<CustomOrigin: %s>r   r   r   r   r   r   v   s    zCustomOrigin.__repr__c                 C   s   d S r   r   r   r   r   r   r   y   s    zCustomOrigin.startElementc                 C   s˜   |dkr|| _ n„|dkrDzt|ƒ| _W q” tk
r@   || _Y q”X nP|dkrxzt|ƒ| _W q” tk
rt   || _Y q”X n|dkrˆ|| _nt| ||ƒ d S )Nr   ZHTTPPortZ	HTTPSPortZOriginProtocolPolicy)r   Úintr(   Ú
ValueErrorr)   r*   r   r   r   r   r   r   |   s    zCustomOrigin.endElementc                 C   sH   d}|d| j  7 }|d| j 7 }|d| j 7 }|d| j 7 }|d7 }|S )Nz  <CustomOrigin>
r   z    <HTTPPort>%d</HTTPPort>
z    <HTTPSPort>%d</HTTPSPort>
z4    <OriginProtocolPolicy>%s</OriginProtocolPolicy>
z  </CustomOrigin>
r'   )r   r   r   r   r   r   Ž   s    zCustomOrigin.to_xml)Nr%   r&   Nr   r   r   r   r   r$   Q   s     ÿ
r$   N)Zboto.cloudfront.identityr   r	   Úobjectr
   r$   r   r   r   r   Ú<module>   s   2