o ckF[;[@sddlmZddlZddlZddlZddlZddlmZddlm Z ddl Zddl m Z ddl mZddlmZmZdZd ZGd d d eZdS) ) exceptionN)AWSAuthConnection)handler)ResourceRecordSetsZone)sixurlliba %(name)s %(caller_ref)s %(comment)s a` %(name)s %(vpc_id)s %(vpc_region)s %(caller_ref)s %(comment)s c seZdZdZ dZ dZ dddddedddddf fdd Zd d Zd2fd d Zd3ddZ ddZ ddZ d4ddZ ddZ dZd5ddZd3ddZddZd d!Z  d6d"d#Zd$d%Zd&d'Z  d7d(d)Zd*d+Zd,d-Zd.d/Zd0d1ZZS)8Route53Connectionzroute53.amazonaws.comz 2013-04-01z-https://route53.amazonaws.com/doc/2013-04-01/NrTc s,tt|j|||d|||||| | | d dS)NT)debugsecurity_tokenvalidate_certshttps_connection_factory profile_name)superr __init__) selfaws_access_key_idaws_secret_access_keyportproxy proxy_porthostr r r rr __class__9/usr/lib/python3/dist-packages/boto/route53/connection.pyrLs   zRoute53Connection.__init__cCsdgS)Nroute53rrrrr_required_auth_capabilityZsz+Route53Connection._required_auth_capabilityc sr|r+g}t|D]\}}|durq ||dtjt|q |dd|7}tt |j |||||j dS)N=?&) retry_handler) r iteritemsappendr parsequotestrjoinrr make_request_retry_handler) ractionpathheadersdataparamspairskeyvalrrrr+]s  zRoute53Connection.make_requestc Csi}|rd|i}|jdd|j|d}|}tj||jdkr+t|j|j |tj j ddd}tj |d }| ||rJ|d d|d |d vrh|d d }|d d}|||}d |d vsP|S) aA Returns a Python data structure with information about all Hosted Zones defined for the AWS account. :param int start_marker: start marker to pass when fetching additional results after a truncated list :param list zone_list: a HostedZones list to prepend to results markerGET/%s/hostedzoner1, HostedZones) HostedZone list_marker item_markerNListHostedZonesResponse NextMarker)r+Versionreadbotologr statusrDNSServerErrorreason jsonresponseElement XmlHandlerr'extendget_all_hosted_zones) r start_marker zone_listr1responsebodyeh next_markerrrrrLks4         z&Route53Connection.get_all_hosted_zonescCsvd|j|f}|d|}|}tj||jdkr%t|j|j |tj j ddd}tj |d}| ||S)z Get detailed information about a particular Hosted Zone. :type hosted_zone_id: str :param hosted_zone_id: The unique identifier for the Hosted Zone /%s/hostedzone/%sr6r9 NameServers NameServerr<NrAr+rBrCrDr rErrFrGrHrIrJr'rhosted_zone_idurirOrPrQrRrrrget_hosted_zones    z!Route53Connection.get_hosted_zonecCsZ|ddkr |d7}|}|ddD]}|d|kr*||dddSqdS) z Get detailed information about a particular Hosted Zone. :type hosted_zone_name: str :param hosted_zone_name: The fully qualified domain name for the Hosted Zone .r?r:NameId/N)rLr\split)rhosted_zone_nameall_hosted_zoneszonerrrget_hosted_zone_by_names  z)Route53Connection.get_hosted_zone_by_nameFcCs|dur tt}|r||||||jd}t|}n ||||jd}t|}d|j} |d| ddi|} | } t j | | j dkr[t j jd d d } t j | d} | | | St| j | j| ) a^ Create a new Hosted Zone. Returns a Python data structure with information about the newly created Hosted Zone. :type domain_name: str :param domain_name: The name of the domain. This should be a fully-specified domain, and should end with a final period as the last label indication. If you omit the final period, Amazon Route 53 assumes the domain is relative to the root. This is the name you have registered with your DNS registrar. It is also the name you will delegate from your registrar to the Amazon Route 53 delegation servers returned in response to this request.A list of strings with the image IDs wanted. :type caller_ref: str :param caller_ref: A unique string that identifies the request and that allows failed CreateHostedZone requests to be retried without the risk of executing the operation twice. If you don't provide a value for this, boto will generate a Type 4 UUID and use that. :type comment: str :param comment: Any comments you want to include about the hosted zone. :type private_zone: bool :param private_zone: Set True if creating a private hosted zone. :type vpc_id: str :param vpc_id: When creating a private hosted zone, the VPC Id to associate to is required. :type vpc_region: str :param vpc_region: When creating a private hosted zone, the region of the associated VPC is required. N)name caller_refcommentvpc_id vpc_regionxmlns)rgrhrirlr7POST Content-Typetext/xmlrUrVr<)r)uuiduuid4 XMLNameSpaceHZPXMLHZXMLrAr+rBrCrDr rErHrIrJr'rrFrG)r domain_namerhri private_zonerjrkr1xml_bodyr[rOrPrQrRrrrcreate_hosted_zonesD(      z$Route53Connection.create_hosted_zonecCpd|j|f}|d|}|}tj||jdvr%t|j|j |tj }tj |d}| ||S)z Delete the hosted zone specified by the given id. :type hosted_zone_id: str :param hosted_zone_id: The hosted zone's id rTDELETENrXrYrrrdelete_hosted_zone     z$Route53Connection.delete_hosted_zonez %(caller_ref)s %(health_check)s c Cs|dur tt}d|j}|j||d}|j|}|d|ddi|}|}t j ||j dkrIt j }t j |d} | ||St|j |j|)a Create a new Health Check :type health_check: HealthCheck :param health_check: HealthCheck object :type caller_ref: str :param caller_ref: A unique string that identifies the request and that allows failed CreateHealthCheckRequest requests to be retried without the risk of executing the operation twice. If you don't provide a value for this, boto will generate a Type 4 UUID and use that. N/%s/healthcheck)rlrh health_checkrmrnrorp)r)rqrrrArsto_xml POSTHCXMLBodyr+rBrCrDr rErHrIrJr'rrFrG) rrrhr[r1rxrOrPrQrRrrrcreate_health_checks"       z%Route53Connection.create_health_checkc Csi}|dur ||d<|dur||d<d|jf}|jd||d}|}tj||jdkr8t|j|j |tj j dd d }tj |d}| ||S) z Return a list of health checks :type maxitems: int :param maxitems: Maximum number of items to return :type marker: str :param marker: marker to get next set of items to list Nmaxitemsr5rr6r8r9 HealthChecks) HealthCheckr<rX) rrr5r1r[rOrPrQrRrrrget_list_health_checks8s(     z(Route53Connection.get_list_health_checkscCsrd|j}|d|}|}tj||jdkr#t|j|j |tj j ddd}tj |d}| ||S)z@ Return a list of Route53 healthcheck IP ranges z/%s/checkeriprangesr6r9CheckerIpRanges)memberr<NrX)rr[rOrPrQrRrrrget_checker_ip_rangesXs     z'Route53Connection.get_checker_ip_rangescCrz)z Delete a health check :type health_check_id: str :param health_check_id: ID of the health check to delete z/%s/healthcheck/%sr{r|NrX)rhealth_check_idr[rOrPrQrRrrrdelete_health_checkirz%Route53Connection.delete_health_checkc Cs||||d}d|j|f}|jd||d}|} tj| |jdkr.t|j|j | t ||d} t | |} t j| | | S)a Retrieve the Resource Record Sets defined for this Hosted Zone. Returns the raw XML data returned by the Route53 call. :type hosted_zone_id: str :param hosted_zone_id: The unique identifier for the Hosted Zone :type type: str :param type: The type of resource record set to begin the record listing from. Valid choices are: * A * AAAA * CNAME * MX * NS * PTR * SOA * SPF * SRV * TXT Valid values for weighted resource record sets: * A * AAAA * CNAME * TXT Valid values for Zone Apex Aliases: * A * AAAA :type name: str :param name: The first name in the lexicographic ordering of domain names to be retrieved :type identifier: str :param identifier: In a hosted zone that includes weighted resource record sets (multiple resource record sets with the same DNS name and type that are differentiated only by SetIdentifier), if results were truncated for a given DNS name and type, the value of SetIdentifier for the next resource record set that has the current DNS name and type :type maxitems: int :param maxitems: The maximum number of records )typerg identifierr/%s/hostedzone/%s/rrsetr6r8r9) connectionrZ)rAr+rBrCrDr rErrFrGrrrJxmlsax parseString) rrZrrgrrr1r[rOrPrsrRrrrget_all_rrsetss 4    z Route53Connection.get_all_rrsetscCsxd|j|f}|d|ddi|}|}tj||jdkr)t|j|j |tj }tj |d}| ||S)a Create or change the authoritative DNS information for this Hosted Zone. Returns a Python data structure with information about the set of changes, including the Change ID. :type hosted_zone_id: str :param hosted_zone_id: The unique identifier for the Hosted Zone :type xml_body: str :param xml_body: The list of changes to be made, defined in the XML schema defined by the Route53 service. rrmrnror9NrX)rrZrxr[rOrPrQrRrrr change_rrsetss     zRoute53Connection.change_rrsetscCspd|j|f}|d|}|}tj||jdkr%t|j|j |tj }tj |d}| ||S)a Get information about a proposed set of changes, as submitted by the change_rrsets method. Returns a Python data structure with status information about the changes. :type change_id: str :param change_id: The unique identifier for the set of changes. This ID is returned in the response to the change_rrsets method. z /%s/change/%sr6r9NrX)r change_idr[rOrPrQrRrrr get_changes     zRoute53Connection.get_changecCs$|j||||d}t||ddS)a# Create a new Hosted Zone. Returns a Zone object for the newly created Hosted Zone. :type name: str :param name: The name of the domain. This should be a fully-specified domain, and should end with a final period as the last label indication. If you omit the final period, Amazon Route 53 assumes the domain is relative to the root. This is the name you have registered with your DNS registrar. It is also the name you will delegate from your registrar to the Amazon Route 53 delegation servers returned in response to this request. :type private_zone: bool :param private_zone: Set True if creating a private hosted zone. :type vpc_id: str :param vpc_id: When creating a private hosted zone, the VPC Id to associate to is required. :type vpc_region: str :param vpc_region: When creating a private hosted zone, the region of the associated VPC is required. )rwrjrkCreateHostedZoneResponser;)ryr)rrgrwrjrkrerrr create_zoneszRoute53Connection.create_zonecCs.||}|D] }||jkr|Sq dS)z Returns a Zone object for the specified Hosted Zone. :param name: The name of the domain. This should be a fully-specified domain, and should end with a final period as the last label indication. N)_make_qualified get_zonesrg)rrgrerrrget_zones   zRoute53Connection.get_zonecs"}fdd|ddDS)z Returns a list of Zone objects, one for each of the Hosted Zones defined for the AWS account. :rtype: list :returns: A list of Zone objects. csg|]}t|qSrr).0rerrr 0sz/Route53Connection.get_zones..r?r:)rL)rzonesrrrr&s  zRoute53Connection.get_zonescCsrt|tttfvr'g}|D]}|r|ddks|d|q ||q |S|}|r7|ddks7d|}|S)z Ensure passed domain names end in a period (.) character. This will usually make a domain fully qualified. r]r^z%s.)rlisttuplesetr&strip)rvaluenew_listrecordrrrr3s z!Route53Connection._make_qualifiedcCsd}tjd|j|jdkrH|}t|j|j|}|jrH|jdvr'|Sd|j|f}t t d|tj ddd}|d 7}|||f}|S) NzSaw HTTP status: %si)PriorRequestNotComplete ThrottlingServiceUnavailableRequestExpiredz%s, retry attempt %sBotomax_retry_delay<) rCrDr rErBrrFrG error_codeminrandomconfigget)rrOi next_sleeprErPerrmsgrrrr,Fs,   z Route53Connection._retry_handler)Nr N)NN)Nr FNN)N)NNNN)FNN)__name__ __module__ __qualname__ DefaultHostrArsrrr+rLr\rfryrrrrrrrrrrrrrr, __classcell__rrrrr BsN   H  "  C   r ) boto.route53rrrqxml.saxrrCboto.connectionrrboto.jsonresponseboto.route53.recordrboto.route53.zoner boto.compatrr rurtr rrrrs