o ckF[g?@sDdZddlZddlmZddlmZddlmZGdddeZ dS)<N)TooManyRecordsException)ResourceRecordSets)Statusc@seZdZdZddZddZddZ d5d d Z d6d dZ d7ddZ d5ddZ d7ddZ d7ddZ d7ddZ d8ddZd9ddZd9dd Zd9d!d"Zd7d#d$Zd7d%d&Zd7d'd(Zd:d)d*Zd:d+d,Zd:d-d.Zd/d0Zd1d2Zd3d4Zd S);Zonez A Route53 Zone. :ivar route53connection: A :class:`boto.route53.connection.Route53Connection` connection :ivar id: The ID of the hosted zone cCsD||_|D]}|dkr|ddd|_q||||qdS)NIdz /hostedzone/)route53connectionreplaceid __setattr__lower)selfr zone_dictkeyr3/usr/lib/python3/dist-packages/boto/route53/zone.py__init__(s z Zone.__init__cCs d|jS)Nz )namerrrr__repr__0s z Zone.__repr__cCs|}|ddS)z Commit a set of changes and return the ChangeInfo portion of the response. :type changes: ResourceRecordSets :param changes: changes to be committed ChangeResourceRecordSetsResponse ChangeInfo)commit)rchangesresponserrr_commit3s z Zone._commitrc Csd}d} |dur%zt|d|d}|d}Wn |d} |d}Y|jd|||||| d} t|tttfvrF|D]} | | qs&     zZone._new_recordrNc Cs8t|j|j|}||||||||t|j||S)z Add a new record to this Zone. See _new_record for parameter documentation. Returns a Status object. )rr r r/rr)rr)rr*r+rr,rrrr add_recordos zZone.add_recordc CsZ|pt}t|}t|j|j|}|d||||j|j||||t |j| |S)a  Update an existing record in this Zone. Returns a Status object. :type old_record: ResourceRecord :param old_record: A ResourceRecord (e.g. returned by find_records) See _new_record for additional parameter documentation. DELETE) default_ttlcopyrr r add_change_recordr/r$rrr)r old_record new_valuenew_ttlnew_identifierr,r.rrrr update_recordzs  zZone.update_recordcCsXt|j|j|}t|tttfvr|D]}|d|qn|d|t|j| |S)a8 Delete one or more records from this Zone. Returns a Status object. :param record: A ResourceRecord (e.g. returned by find_records) or list, tuple, or set of ResourceRecords. :type comment: str :param comment: A comment that will be stored with the change. r1) rr r r$r%r&r'r4rr)rr.r,rrrrr delete_records  zZone.delete_recordcCs6|pt}|j|}|j|}|jd|||||dS)z Add a new CNAME record to this Zone. See _new_record for parameter documentation. Returns a Status object. CNAMEr)rr*r+rr,r2r _make_qualifiedr0rrr*r+rr,rrr add_cnames  zZone.add_cnamecCs*|pt}|j|}|jd|||||dS)z Add a new A record to this Zone. See _new_record for parameter documentation. Returns a Status object. Ar=r>r@rrradd_a z Zone.add_acCs*|pt}|j|}|jd|||||dS)z Add a new MX record to this Zone. See _new_record for parameter documentation. Returns a Status object. MXr=r>)rrrecordsr+rr,rrradd_mxrDz Zone.add_mxrFc s,|j|}|jj|j||d}g}|D]}|j|kr&|j|kr&||qdddurDz tddWndYdurRfdd|D}dur`fdd|D}|st||krd||f} | d7} | d d d|D7} t | t|dkr|St|dkr|d SdS) a Search this Zone for records that match given parameters. Returns None if no results, a ResourceRecord if one result, or a ResourceRecordSets if more than one result. :type name: str :param name: The name of the records should match this parameter :type type: str :param type: The type of the records should match this parameter :type desired: int :param desired: The number of desired results. If the number of matching records in the Zone exceeds the value of this parameter, throw TooManyRecordsException :type all: Boolean :param all: If true return all records that match name, type, and identifier parameters :type identifier: Tuple :param identifier: A tuple specifying WRR or LBR attributes. Valid forms are: * (str, int): WRR record [e.g. ('foo',10)] * (str, str): LBR record [e.g. ('foo','us-east-1') )rr$Nrc(g|]}|jkr|jdkr|qSr)r r.0r:)rr rr z%Zone.find_records..crHrI)r!rrJ)rr!rrrLrMzSearch: name %s type %sz Found: z, cSs"g|] }d|j|j|fqS)z%s %s %s)rr$to_printrJrrrrLsr) r r?get_all_rrsetsr rr$appendr"lenjoinr) rrr$desiredallrreturnedresultsr:messager)rr!r r find_recordssB           zZone.find_recordscC|j|d|dS)z Search this Zone for CNAME records that match name. Returns a ResourceRecord. If there is more than one match return all as a ResourceRecordSets if all is True, otherwise throws TooManyRecordsException. r<rTrXrrrTrrr get_cname zZone.get_cnamecCrY)z Search this Zone for A records that match name. Returns a ResourceRecord. If there is more than one match return all as a ResourceRecordSets if all is True, otherwise throws TooManyRecordsException. rBrZr[r\rrrget_ar^z Zone.get_acCrY)z Search this Zone for MX records that match name. Returns a ResourceRecord. If there is more than one match return all as a ResourceRecordSets if all is True, otherwise throws TooManyRecordsException. rErZr[r\rrrget_mx*r^z Zone.get_mxcC@|j|}|j|}||}|p|j}|j|||||dS)z Update the given CNAME record in this Zone to a new value, ttl, and identifier. Returns a Status object. Will throw TooManyRecordsException is name, value does not match a single record. r6r7r8r,)r r?r]r+r9rrr*r+rr,r5rrr update_cname6    zZone.update_cnamecCs4|j|}||}|p|j}|j|||||dS)z Update the given A record in this Zone to a new value, ttl, and identifier. Returns a Status object. Will throw TooManyRecordsException is name, value does not match a single record. rb)r r?r_r+r9rcrrrupdate_aHs   z Zone.update_acCra)z Update the given MX record in this Zone to a new value, ttl, and identifier. Returns a Status object. Will throw TooManyRecordsException is name, value does not match a single record. rb)r r?r`r+r9rcrrr update_mxYrezZone.update_mxcC(|j|}|j|d||d}||S)z Delete a CNAME record matching name and identifier from this Zone. Returns a Status object. If there is more than one match delete all matching records if all is True, otherwise throws TooManyRecordsException. r<rrTr r?rXr;rrrrTr.rrr delete_cnamek   zZone.delete_cnamecCrh)z Delete an A record matching name and identifier from this Zone. Returns a Status object. If there is more than one match delete all matching records if all is True, otherwise throws TooManyRecordsException. rBrirjrkrrrdelete_axrmz Zone.delete_acCrh)z Delete an MX record matching name and identifier from this Zone. Returns a Status object. If there is more than one match delete all matching records if all is True, otherwise throws TooManyRecordsException. rErirjrkrrr delete_mxrmzZone.delete_mxcCs|j|jS)zS Return a ResourceRecordsSets for all of the records in this zone. )r rOr rrrr get_recordsszZone.get_recordscCs|j|jdS)z> Request that this zone be deleted by Amazon. N)r delete_hosted_zoner rrrrdeletesz Zone.deletecCs ||jd}|dur|j}|S)z+ Get the list of nameservers for this zone.NSN)rXrresource_records)rnsrrrget_nameserversszZone.get_nameservers)r)rNr)NNr)rFN)F)NF)__name__ __module__ __qualname____doc__rrrr/r0r9r;rArCrGrXr]r_r`rdrfrgrlrnrorprrrvrrrrr!s< 1        I      r) r2r3boto.exceptionrboto.route53.recordrboto.route53.statusrobjectrrrrrs