o ckF[H;@sddlZddlZddlZddlmZddlmZddlmZm Z m Z ddlm Z m Z m Z ddlmZddlmZddlmZdd lmZmZmZdd lmZdd lmZGd d d eZdS)N)AWSAuthConnection)handler) DistributionDistributionSummaryDistributionConfig)StreamingDistributionStreamingDistributionSummaryStreamingDistributionConfig)OriginAccessIdentity)OriginAccessIdentitySummary)OriginAccessIdentityConfig)InvalidationBatchInvalidationSummaryInvalidationListResultSet) ResultSet)CloudFrontServerErrorc sHeZdZdZdZdddddedddddf fdd Zdd Zd d Z  dCd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZ dDd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Z dDd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8ZdEd9d:Zd;d<Z dFd=d>Z dFd?d@Z!  dCdAdBZ"Z#S)GCloudFrontConnectionzcloudfront.amazonaws.comz 2010-11-01NrTc s,tt|j|||d|||||| | | d dS)NT)debugsecurity_tokenvalidate_certshttps_connection_factory profile_name)superr__init__) selfaws_access_key_idaws_secret_access_keyportproxy proxy_porthostrrrrr __class__:/usr/lib/python3/dist-packages/boto/cloudfront/__init__.pyr+s   zCloudFrontConnection.__init__cCs0|j}|D]}|dkr||SqdS)Netag)msgkeyslower)rresponseresponse_headerskeyr#r#r$get_etag7s    zCloudFrontConnection.get_etagcCsdgS)N cloudfrontr#)rr#r#r$_required_auth_capability>sz.CloudFrontConnection._required_auth_capabilityc Cs|sdtfg}|dd|j|f}|}tj||jdkr)t|j|j ||p,t }|p1t }||fi|} t | |} tj|| | S)NrGET/%s/%s,)r make_requestVersionreadbotologrstatusrreasonrdictr XmlHandlerxmlsax parseString) rresourcetagsresult_set_classresult_set_kwargsr)bodyrs_class rs_kwargsrshr#r#r$_get_all_objectsCs      z%CloudFrontConnection._get_all_objectsc Csd|j||f}|d|}|}tj||jdkr%t|j|j|||d}|j }| D] } | dkr>|| |_ q1t ||} tj|| |S)N /%s/%s/%sr/r1 connectionr%)r3r2r4r5r6rr7rr8r&r'r(r%rr:r;r<r=) ridr> dist_classurir)rBdr*r+rFr#r#r$ _get_infoTs        zCloudFrontConnection._get_infoc Cs~d|j||f}|d|}|}tj||jdkr%t|j|j|||d}| ||_ t ||}t j|||S)N/%s/%s/%s/configr/r1rI)r3r2r4r5r6rr7rr8r,r%rr:r;r<r=) rrKr> config_classrMr)rBrNrFr#r#r$ _get_configds      z CloudFrontConnection._get_configc Cszt|trd}nd}d|j||f}|dd}|d|||}|}tj||j dkr8t |j |j || |S)Nstreaming-distribution distributionrPtext/xml)If-Match Content-TypePUT) isinstancer r3r2to_xmlr4r5r6rr7rr8r,) rdistribution_idr%configr>rMheadersr)rBr#r#r$ _set_configqs     z CloudFrontConnection._set_configcCs|jdd|j|fddi|d}|}tj||jdkr;||d}t ||}t j ||| ||_|St|j|j|)NPOSTr0rWrUdatarI)r2r3r[r4r5r6rr7rr:r;r<r=r,r%rr8)rr]r>rLr)rBrNrFr#r#r$_create_objects      z#CloudFrontConnection._create_objectcCsTd|j||f}|d|d|i}|}tj||jdkr(t|j|j|dS)NrHDELETErV) r3r2r4r5r6rr7rr8)rrKr%r>rMr)rBr#r#r$_delete_objects  z#CloudFrontConnection._delete_objectcCdtfg}|d|S)NrrT)rrGrr?r#r#r$get_all_distributions  z*CloudFrontConnection.get_all_distributionscC||dtSNrT)rOrrr\r#r#r$get_distribution_infoz*CloudFrontConnection.get_distribution_infocCrlrm)rRrrnr#r#r$get_distribution_configz,CloudFrontConnection.get_distribution_configcC||||SNr_rr\r%r]r#r#r$set_distribution_configrpz,CloudFrontConnection.set_distribution_configcC"t||||||d}||dtS)Noriginenabledcaller_referencecnamescommenttrusted_signersrT)rrdrrr{r|r}r~rrr]r#r#r$create_distributions z(CloudFrontConnection.create_distributioncC|||dSrmrgrr\r%r#r#r$delete_distributionrpz(CloudFrontConnection.delete_distributioncCrh)NrrS)rrGrir#r#r$get_all_streaming_distributionsrkz4CloudFrontConnection.get_all_streaming_distributionscCrlNrS)rOrrnr#r#r$get_streaming_distribution_inforrz4CloudFrontConnection.get_streaming_distribution_infocCrlr)rRr rnr#r#r$!get_streaming_distribution_configrrz6CloudFrontConnection.get_streaming_distribution_configcCrsrtrurvr#r#r$!set_streaming_distribution_configrpz6CloudFrontConnection.set_streaming_distribution_configcCry)NrzrS)r rdrrr#r#r$create_streaming_distributionsz2CloudFrontConnection.create_streaming_distributioncCrrrrr#r#r$delete_streaming_distributionrrz2CloudFrontConnection.delete_streaming_distributioncCrh)N%CloudFrontOriginAccessIdentitySummary!origin-access-identity/cloudfront)r rGrir#r#r$get_all_origin_access_identitys z3CloudFrontConnection.get_all_origin_access_identitycCrlNr)rOr r access_idr#r#r$get_origin_access_identity_inforrz4CloudFrontConnection.get_origin_access_identity_infocCrlr)rRr rr#r#r$!get_origin_access_identity_configsz6CloudFrontConnection.get_origin_access_identity_configcCrsrtru)rrr%r]r#r#r$!set_origin_access_identity_configsz6CloudFrontConnection.set_origin_access_identity_configcCst||d}||dtS)N)r}rr)r rdr )rr}rr]r#r#r$create_origin_access_identitys z2CloudFrontConnection.create_origin_access_identitycCrrr)rrr%r#r#r$delete_origin_access_identityrrz2CloudFrontConnection.delete_origin_access_identitycCst|ts t|}||_d|j|f}|jd|ddi|d}|}|jdkr8t ||}t j |||St |j|j|)zQCreates a new invalidation request :see: http://goo.gl/8vECq z /%s/distribution/%s/invalidationr`rWrUrarc)rZr rJr3r2r[r4r7rr:r;r<r=rr8)rr\pathsr}rMr)rBrFr#r#r$create_invalidation_requests   z0CloudFrontConnection.create_invalidation_requestc Csjd|j||f}|d|ddi}|}|jdkr-tg}t||}tj |||St |j|j |)Nz#/%s/distribution/%s/invalidation/%sr/rWrUrY) r3r2r4r7r rr:r;r<r=rr8) rr\ request_idr}rMr)rBrrFr#r#r$invalidation_request_status s  z0CloudFrontConnection.invalidation_request_statusc Csd|}t}|r ||d<|r||d<|r.|d|7}|D] \}}|d||f7}q!dtfg}t} t||||d} |j||| | dS) a Get all invalidation requests for a given CloudFront distribution. This returns an instance of an InvalidationListResultSet that automatically handles all of the result paging, etc. from CF - you just need to keep iterating until there are no more results. :type distribution_id: string :param distribution_id: The id of the CloudFront distribution :type marker: string :param marker: Use this only when paginating results and only in follow-up request after you've received a response where the results are truncated. Set this to the value of the Marker element in the response you just received. :type max_items: int :param max_items: Use this only when paginating results and only in a follow-up request to indicate the maximum number of invalidation requests you want in the response. You will need to pass the next_marker property from the previous InvalidationListResultSet response in the follow-up request in order to get the next 'page' of results. :rtype: :class:`boto.cloudfront.invalidation.InvalidationListResultSet` :returns: An InvalidationListResultSet iterator that lists invalidation requests for a given CloudFront distribution. Automatically handles paging the results. zdistribution/%s/invalidationMarkerMaxItemsz?%s=%sz&%s=%sr)rJr\ max_itemsmarker)r@rA)r9popitemitemsrrrG) rr\rrrMparamskvr?rCrDr#r#r$get_invalidation_requestss$  z.CloudFrontConnection.get_invalidation_requests)NN)rxNrxN)rxrxrt)$__name__ __module__ __qualname__ DefaultHostr3rr,r.rGrOrRr_rdrgrjrorqrwrrrrrrrrrrrrrrrrr __classcell__r#r#r!r$r&s`          r)xml.saxr;timer5boto.connectionrrboto.cloudfront.distributionrrrrrr boto.cloudfront.identityr r r boto.cloudfront.invalidationr rrboto.resultsetrboto.cloudfront.exceptionrrr#r#r#r$s