ó
è?F[c           @   s^   d  d d d d d d d g Z  d d	 l m Z d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   t   At   AAAAt   TXTt   CNAMEt   MXt   PTRt   SRVt   SPFiÿÿÿÿ(   t	   ResultSett   ResourceRecordSetsc        
   B   s†   e  Z d  Z d Z d Z d d d d „ Z d „  Z d d d d d d d d d d „	 Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z RS(   sÃ   
    A list of resource records.

    :ivar hosted_zone_id: The ID of the hosted zone.
    :ivar comment: A comment that will be stored with the change.
    :ivar changes: A list of changes.
    s@  <?xml version="1.0" encoding="UTF-8"?>
    <ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
            <ChangeBatch>
                <Comment>%(comment)s</Comment>
                <Changes>%(changes)s</Changes>
            </ChangeBatch>
        </ChangeResourceRecordSetsRequest>sM   <Change>
        <Action>%(action)s</Action>
        %(record)s
    </Change>c         C   sb   | |  _  | |  _ | |  _ g  |  _ d  |  _ d  |  _ d  |  _ t t	 |  ƒ j
 d t f g ƒ d  S(   Nt   ResourceRecordSet(   t
   connectiont   hosted_zone_idt   commentt   changest   Nonet   next_record_namet   next_record_typet   next_record_identifiert   superR	   t   __init__t   Record(   t   selfR   R   R   (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyR   4   s    							c         C   sp   |  j  r7 d j g  |  j  D] } | j ƒ  ^ q ƒ } n( d j g  |  D] } | j ƒ  ^ qD ƒ } d |  j | f S(   Nt   ,s   <ResourceRecordSets:%s [%s](   R   t   joint   __repr__R   (   R   t   ct   record_listt   record(    (    s2   lib/python2.7/site-packages/boto/route53/record.pyR   >   s
    	.(	iX  c         C   s\   t  | | | d | d | d | d | d |	 d |
 d | d | ƒ} |  j j | | g ƒ | S(	   sÑ	  
        Add a change request to the set.

        :type action: str
        :param action: The action to perform ('CREATE'|'DELETE'|'UPSERT')

        :type name: str
        :param name: The name of the domain you want to perform the action on.

        :type type: str
        :param type: The DNS record type.  Valid values are:

            * A
            * AAAA
            * CNAME
            * MX
            * NS
            * PTR
            * SOA
            * SPF
            * SRV
            * TXT

        :type ttl: int
        :param ttl: The resource record cache time to live (TTL), in seconds.

        :type alias_hosted_zone_id: str
        :param alias_dns_name: *Alias resource record sets only* The value
            of the hosted zone ID, CanonicalHostedZoneNameId, for
            the LoadBalancer.

        :type alias_dns_name: str
        :param alias_hosted_zone_id: *Alias resource record sets only*
            Information about the domain to which you are redirecting traffic.

        :type identifier: str
        :param identifier: *Weighted and latency-based resource record sets
            only* An identifier that differentiates among multiple resource
            record sets that have the same combination of DNS name and type.

        :type weight: int
        :param weight: *Weighted resource record sets only* Among resource
            record sets that have the same combination of DNS name and type,
            a value that determines what portion of traffic for the current
            resource record set is routed to the associated location

        :type region: str
        :param region: *Latency-based resource record sets only* Among resource
            record sets that have the same combination of DNS name and type,
            a value that determines which region this should be associated with
            for the latency-based routing

        :type alias_evaluate_target_health: bool
        :param alias_evaluate_target_health: *Required for alias resource record
            sets* Indicates whether this Resource Record Set should respect the
            health status of any health checks associated with the ALIAS target
            record which it is linked to.

        :type health_check: str
        :param health_check: Health check to associate with this record

        :type failover: str
        :param failover: *Failover resource record sets only* Whether this is the
            primary or secondary resource record set.
        t   alias_hosted_zone_idt   alias_dns_namet
   identifiert   weightt   regiont   alias_evaluate_target_healtht   health_checkt   failover(   R   R   t   append(   R   t   actiont   namet   typet   ttlR   R   R   R    R!   R"   R#   R$   t   change(    (    s2   lib/python2.7/site-packages/boto/route53/record.pyt
   add_changeF   s    Ec         C   s   |  j  j | | g ƒ d S(   s@   Add an existing record to a change set with the specified actionN(   R   R%   (   R   R&   R*   (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyt   add_change_record”   s    c         C   so   d } xD |  j  D]9 } i | d d 6| d j ƒ  d 6} | |  j | 7} q Wi |  j d 6| d 6} |  j | S(   sc   Convert this ResourceRecordSet into XML
        to be saved via the ChangeResourceRecordSetsRequestt    i    R&   i   R   R   R   (   R   t   to_xmlt	   ChangeXMLR   t   ChangeResourceRecordSetsBody(   R   t
   changesXMLR*   t   changeParamst   params(    (    s2   lib/python2.7/site-packages/boto/route53/record.pyR.   ™   s    "c         C   sC   |  j  s' d d l } | j ƒ  |  _  n  |  j  j |  j |  j ƒ  ƒ S(   s   Commit this changeiÿÿÿÿN(   R   t   botot   connect_route53t   change_rrsetsR   R.   (   R   R4   (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyt   commit£   s    	c         C   sh   | d k r | |  _  nL | d k r0 | |  _ n4 | d k rH | |  _ n t t |  ƒ j | | | ƒ Sd S(   sn   Overwritten to also add the NextRecordName,
        NextRecordType and NextRecordIdentifier to the base objectt   NextRecordNamet   NextRecordTypet   NextRecordIdentifierN(   R   R   R   R   R	   t
   endElement(   R   R'   t   valueR   (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyR;   ª   s    c         c   s™   t  t |  ƒ j ƒ  } |  j } xt | r” x | D] } | Vq. W|  j r‚ t |  _ |  j j |  j d |  j d |  j	 d |  j
 ƒ} q! d } | |  _ q! Wd S(   s,   Override the next function to support pagingR'   R(   R   N(   R   R	   t   __iter__t   is_truncatedt   FalseR   t   get_all_rrsetsR   R   R   R   R   (   R   t   resultst	   truncatedt   obj(    (    s2   lib/python2.7/site-packages/boto/route53/record.pyR=   ¶   s    						N(   t   __name__t
   __module__t   __doc__R0   R/   R   R   R   R+   R,   R.   R7   R;   R=   (    (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyR	      s   
			K		
		R   c           B   s³   e  Z d  Z d Z d Z d Z d Z d Z d Z d Z	 d Z
 d	 Z d d d
 d d d d d d d d d d „ Z d „  Z d „  Z e d „ Z d „  Z d „  Z d „  Z d „  Z RS(   s   An individual ResourceRecordSets!   <HealthCheckId>%s</HealthCheckId>s¥   <ResourceRecordSet>
        <Name>%(name)s</Name>
        <Type>%(type)s</Type>
        %(weight)s
        %(body)s
        %(health_check)s
    </ResourceRecordSet>s_   
        <SetIdentifier>%(identifier)s</SetIdentifier>
        <Weight>%(weight)s</Weight>
    s_   
        <SetIdentifier>%(identifier)s</SetIdentifier>
        <Region>%(region)s</Region>
    se   
        <SetIdentifier>%(identifier)s</SetIdentifier>
        <Failover>%(failover)s</Failover>
    sh   
        <TTL>%(ttl)s</TTL>
        <ResourceRecords>
            %(records)s
        </ResourceRecords>s@   <ResourceRecord>
        <Value>%s</Value>
    </ResourceRecord>sŸ   <AliasTarget>
        <HostedZoneId>%(hosted_zone_id)s</HostedZoneId>
        <DNSName>%(dns_name)s</DNSName>
        %(eval_target_health)s
    </AliasTarget>s/   <EvaluateTargetHealth>%s</EvaluateTargetHealth>iX  c         C   s…   | |  _  | |  _ | |  _ | d  k r0 g  } n  | |  _ | |  _ | |  _ | |  _ | |  _ |	 |  _	 |
 |  _
 | |  _ | |  _ d  S(   N(   R'   R(   R)   R   t   resource_recordsR   R   R   R    R!   R"   R#   R$   (   R   R'   R(   R)   RG   R   R   R   R    R!   R"   R#   R$   (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyR   õ   s    												c         C   s   d |  j  |  j |  j ƒ  f S(   Ns   <Record:%s:%s:%s>(   R'   R(   t   to_print(   R   (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyR     s    c         C   s   |  j  j | ƒ d S(   s   Add a resource record valueN(   RG   R%   (   R   R<   (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyt	   add_value  s    c         C   s   | |  _  | |  _ | |  _ d S(   s&   Make this an alias resource record setN(   R   R   R"   (   R   R   R   R"   (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyt	   set_alias  s    		c         C   sô  |  j  d k	 r} |  j d k	 r} |  j d k	 rL |  j |  j rB d n d } n d } |  j i |  j  d 6|  j d 6| d 6} nI d } x" |  j D] } | |  j | 7} q W|  j i |  j	 d 6| d 6} d } |  j
 d k	 r|  j d k	 r|  j i |  j
 d	 6|  j d
 6} n„ |  j
 d k	 rP|  j d k	 rP|  j i |  j
 d	 6|  j d 6} nB |  j
 d k	 r’|  j d k	 r’|  j i |  j
 d	 6|  j d 6} n  d } |  j d k	 rº|  j |  j } n  i |  j d 6|  j d 6| d
 6| d 6| d 6} |  j | S(   s(   Spit this resource record set out as XMLt   truet   falseR-   R   t   dns_namet   eval_target_healthR)   t   recordsR   R    R!   R$   R'   R(   t   bodyR#   N(   R   R   R   R"   t   EvaluateTargetHealtht	   AliasBodyRG   t   ResourceRecordBodyt   ResourceRecordsBodyR)   R   R    t   WRRBodyR!   t   RRRBodyR$   t   FailoverBodyR#   t   HealthCheckBodyR'   R(   t   XMLBody(   R   RN   RP   RO   t   rR    R#   R3   (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyR.     sB    
	



c         C   s)  d } |  j  d  k	 rb |  j d  k	 rb d |  j  d |  j } |  j d  k	 rt | d |  j 7} qt n d j |  j ƒ } |  j d  k	 r¯ |  j d  k	 r¯ | d |  j |  j f 7} nv |  j d  k	 rê |  j d  k	 rê | d |  j |  j f 7} n; |  j d  k	 r%|  j	 d  k	 r%| d |  j |  j	 f 7} n  | S(	   NR-   s   ALIAS t    s    (EvalTarget %s)R   s    (WRR id=%s, w=%s)s    (LBR id=%s, region=%s)s    (FAILOVER id=%s, failover=%s)(
   R   R   R   R"   R   RG   R   R    R!   R$   (   R   t   rr(    (    s2   lib/python2.7/site-packages/boto/route53/record.pyRH   G  s    c         C   s7  | d k r | |  _  n| d k r0 | |  _ n| d k rH | |  _ në | d k rg |  j j | ƒ nÌ | d k r | |  _ n´ | d k r— | |  _ nœ | d k r¯ | |  _ n„ | d k rÓ | j ƒ  d	 k |  _	 n` | d
 k rë | |  _
 nH | d k r| |  _ n0 | d k r| |  _ n | d k r3| |  _ n  d  S(   Nt   Namet   Typet   TTLt   Valuet   HostedZoneIdt   DNSNamet   SetIdentifierRQ   RK   t   Weightt   Regiont   Failovert   HealthCheckId(   R'   R(   R)   RG   R%   R   R   R   t   lowerR"   R    R!   R$   R#   (   R   R'   R<   R   (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyR;   [  s0    c         C   s   d  S(   N(   R   (   R   R'   t   attrsR   (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyt   startElementu  s    N(   RD   RE   RF   RX   RY   RU   RV   RW   RT   RS   RR   RQ   R   R   R   RI   R?   RJ   R.   RH   R;   Rj   (    (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyR   Ç   s*   					1		N(   t   RECORD_TYPESt   boto.resultsetR   R	   t   objectR   (    (    (    s2   lib/python2.7/site-packages/boto/route53/record.pyt   <module>   s   ©