Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

PEP8 and pyflakes cleanup.

  • Loading branch information...
commit 7f4fe40eda8b0ad1c58b647f95bbdaecf2506ffd 1 parent 3e66569
@garnaat garnaat authored
View
96 boto/cloudfront/__init__.py
@@ -14,26 +14,29 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
import xml.sax
-import time
import boto
from boto.connection import AWSAuthConnection
from boto import handler
-from boto.cloudfront.distribution import Distribution, DistributionSummary, DistributionConfig
-from boto.cloudfront.distribution import StreamingDistribution, StreamingDistributionSummary, StreamingDistributionConfig
-from boto.cloudfront.identity import OriginAccessIdentity
-from boto.cloudfront.identity import OriginAccessIdentitySummary
-from boto.cloudfront.identity import OriginAccessIdentityConfig
-from boto.cloudfront.invalidation import InvalidationBatch
+from .distribution import Distribution, DistributionSummary
+from .distribution import DistributionConfig
+from .distribution import StreamingDistribution
+from .distribution import StreamingDistributionSummary
+from .distribution import StreamingDistributionConfig
+from .identity import OriginAccessIdentity
+from .identity import OriginAccessIdentitySummary
+from .identity import OriginAccessIdentityConfig
+from .invalidation import InvalidationBatch
from boto.resultset import ResultSet
from boto.cloudfront.exception import CloudFrontServerError
+
class CloudFrontConnection(AWSAuthConnection):
DefaultHost = 'cloudfront.amazonaws.com'
@@ -57,11 +60,12 @@ def _required_auth_capability(self):
return ['cloudfront']
# Generics
-
+
def _get_all_objects(self, resource, tags):
if not tags:
- tags=[('DistributionSummary', DistributionSummary)]
- response = self.make_request('GET', '/%s/%s' % (self.Version, resource))
+ tags = [('DistributionSummary', DistributionSummary)]
+ response = self.make_request('GET', '/%s/%s' % (self.Version,
+ resource))
body = response.read()
boto.log.debug(body)
if response.status >= 300:
@@ -99,24 +103,26 @@ def _get_config(self, id, resource, config_class):
h = handler.XmlHandler(d, self)
xml.sax.parseString(body, h)
return d
-
+
def _set_config(self, distribution_id, etag, config):
if isinstance(config, StreamingDistributionConfig):
resource = 'streaming-distribution'
else:
resource = 'distribution'
uri = '/%s/%s/%s/config' % (self.Version, resource, distribution_id)
- headers = {'If-Match' : etag, 'Content-Type' : 'text/xml'}
+ headers = {'If-Match': etag, 'Content-Type': 'text/xml'}
response = self.make_request('PUT', uri, headers, config.to_xml())
body = response.read()
boto.log.debug(body)
if response.status != 200:
raise CloudFrontServerError(response.status, response.reason, body)
return self.get_etag(response)
-
+
def _create_object(self, config, resource, dist_class):
- response = self.make_request('POST', '/%s/%s' % (self.Version, resource),
- {'Content-Type' : 'text/xml'}, data=config.to_xml())
+ response = self.make_request('POST', '/%s/%s' % (self.Version,
+ resource),
+ {'Content-Type': 'text/xml'},
+ data=config.to_xml())
body = response.read()
boto.log.debug(body)
if response.status == 201:
@@ -127,19 +133,19 @@ def _create_object(self, config, resource, dist_class):
return d
else:
raise CloudFrontServerError(response.status, response.reason, body)
-
+
def _delete_object(self, id, etag, resource):
uri = '/%s/%s/%s' % (self.Version, resource, id)
- response = self.make_request('DELETE', uri, {'If-Match' : etag})
+ response = self.make_request('DELETE', uri, {'If-Match': etag})
body = response.read()
boto.log.debug(body)
if response.status != 204:
raise CloudFrontServerError(response.status, response.reason, body)
# Distributions
-
+
def get_all_distributions(self):
- tags=[('DistributionSummary', DistributionSummary)]
+ tags = [('DistributionSummary', DistributionSummary)]
return self._get_all_objects('distribution', tags)
def get_distribution_info(self, distribution_id):
@@ -148,10 +154,10 @@ def get_distribution_info(self, distribution_id):
def get_distribution_config(self, distribution_id):
return self._get_config(distribution_id, 'distribution',
DistributionConfig)
-
+
def set_distribution_config(self, distribution_id, etag, config):
return self._set_config(distribution_id, etag, config)
-
+
def create_distribution(self, origin, enabled, caller_reference='',
cnames=None, comment='', trusted_signers=None):
config = DistributionConfig(origin=origin, enabled=enabled,
@@ -159,14 +165,14 @@ def create_distribution(self, origin, enabled, caller_reference='',
cnames=cnames, comment=comment,
trusted_signers=trusted_signers)
return self._create_object(config, 'distribution', Distribution)
-
+
def delete_distribution(self, distribution_id, etag):
return self._delete_object(distribution_id, etag, 'distribution')
# Streaming Distributions
-
+
def get_all_streaming_distributions(self):
- tags=[('StreamingDistributionSummary', StreamingDistributionSummary)]
+ tags = [('StreamingDistributionSummary', StreamingDistributionSummary)]
return self._get_all_objects('streaming-distribution', tags)
def get_streaming_distribution_info(self, distribution_id):
@@ -176,10 +182,10 @@ def get_streaming_distribution_info(self, distribution_id):
def get_streaming_distribution_config(self, distribution_id):
return self._get_config(distribution_id, 'streaming-distribution',
StreamingDistributionConfig)
-
+
def set_streaming_distribution_config(self, distribution_id, etag, config):
return self._set_config(distribution_id, etag, config)
-
+
def create_streaming_distribution(self, origin, enabled,
caller_reference='',
cnames=None, comment='',
@@ -190,15 +196,16 @@ def create_streaming_distribution(self, origin, enabled,
trusted_signers=trusted_signers)
return self._create_object(config, 'streaming-distribution',
StreamingDistribution)
-
+
def delete_streaming_distribution(self, distribution_id, etag):
- return self._delete_object(distribution_id, etag, 'streaming-distribution')
+ return self._delete_object(distribution_id, etag,
+ 'streaming-distribution')
# Origin Access Identity
def get_all_origin_access_identity(self):
- tags=[('CloudFrontOriginAccessIdentitySummary',
- OriginAccessIdentitySummary)]
+ tags = [('CloudFrontOriginAccessIdentitySummary',
+ OriginAccessIdentitySummary)]
return self._get_all_objects('origin-access-identity/cloudfront', tags)
def get_origin_access_identity_info(self, access_id):
@@ -209,27 +216,29 @@ def get_origin_access_identity_config(self, access_id):
return self._get_config(access_id,
'origin-access-identity/cloudfront',
OriginAccessIdentityConfig)
-
+
def set_origin_access_identity_config(self, access_id,
etag, config):
return self._set_config(access_id, etag, config)
-
+
def create_origin_access_identity(self, caller_reference='', comment=''):
config = OriginAccessIdentityConfig(caller_reference=caller_reference,
comment=comment)
return self._create_object(config, 'origin-access-identity/cloudfront',
OriginAccessIdentity)
-
+
def delete_origin_access_identity(self, access_id, etag):
return self._delete_object(access_id, etag,
'origin-access-identity/cloudfront')
# Object Invalidation
-
+
def create_invalidation_request(self, distribution_id, paths,
caller_reference=None):
- """Creates a new invalidation request
- :see: http://goo.gl/8vECq
+ """
+ Creates a new invalidation request
+
+ :see: http://goo.gl/8vECq
"""
# We allow you to pass in either an array or
# an InvalidationBatch object
@@ -239,7 +248,7 @@ def create_invalidation_request(self, distribution_id, paths,
uri = '/%s/distribution/%s/invalidation' % (self.Version,
distribution_id)
response = self.make_request('POST', uri,
- {'Content-Type' : 'text/xml'},
+ {'Content-Type': 'text/xml'},
data=paths.to_xml())
body = response.read()
if response.status == 201:
@@ -249,9 +258,12 @@ def create_invalidation_request(self, distribution_id, paths,
else:
raise CloudFrontServerError(response.status, response.reason, body)
- def invalidation_request_status (self, distribution_id, request_id, caller_reference=None):
- uri = '/%s/distribution/%s/invalidation/%s' % (self.Version, distribution_id, request_id )
- response = self.make_request('GET', uri, {'Content-Type' : 'text/xml'})
+ def invalidation_request_status(self, distribution_id, request_id,
+ caller_reference=None):
+ uri = '/%s/distribution/%s/invalidation/%s' % (self.Version,
+ distribution_id,
+ request_id)
+ response = self.make_request('GET', uri, {'Content-Type': 'text/xml'})
body = response.read()
if response.status == 200:
paths = InvalidationBatch([])
@@ -260,5 +272,3 @@ def invalidation_request_status (self, distribution_id, request_id, caller_refer
return paths
else:
raise CloudFrontServerError(response.status, response.reason, body)
-
-
View
74 boto/cloudfront/distribution.py
@@ -14,23 +14,20 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
import uuid
import base64
-try:
- import simplejson as json
-except ImportError:
- import json
-from boto.cloudfront.identity import OriginAccessIdentity
from boto.cloudfront.object import Object, StreamingObject
from boto.cloudfront.signers import ActiveTrustedSigners, TrustedSigners
from boto.cloudfront.logging import LoggingInfo
from boto.cloudfront.origin import S3Origin, CustomOrigin
from boto.s3.acl import ACL
+import boto.compat as compat
+
class DistributionConfig:
@@ -39,35 +36,36 @@ def __init__(self, connection=None, origin=None, enabled=False,
trusted_signers=None, default_root_object=None,
logging=None):
"""
+ :type origin: :class:`boto.cloudfront.origin.S3Origin` or
+ :class:`boto.cloudfront.origin.CustomOrigin`
:param origin: Origin information to associate with the
distribution. If your distribution will use
an Amazon S3 origin, then this should be an
S3Origin object. If your distribution will use
a custom origin (non Amazon S3), then this
should be a CustomOrigin object.
- :type origin: :class:`boto.cloudfront.origin.S3Origin` or
- :class:`boto.cloudfront.origin.CustomOrigin`
+ :type enabled: bool
:param enabled: Whether the distribution is enabled to accept
end user requests for content.
- :type enabled: bool
-
+
+ :type enabled: str
:param caller_reference: A unique number that ensures the
request can't be replayed. If no
caller_reference is provided, boto
will generate a type 4 UUID for use
as the caller reference.
- :type enabled: str
-
+
+ :type enabled: array of str
:param cnames: A CNAME alias you want to associate with this
distribution. You can have up to 10 CNAME aliases
per distribution.
- :type enabled: array of str
-
+
+ :type comment: str
:param comment: Any comments you want to include about the
distribution.
- :type comment: str
-
+
+ :type trusted_signers: :class`boto.cloudfront.signers.TrustedSigners`
:param trusted_signers: Specifies any AWS accounts you want to
permit to create signed URLs for private
content. If you want the distribution to
@@ -75,20 +73,18 @@ def __init__(self, connection=None, origin=None, enabled=False,
TrustedSigners object; if you want the
distribution to use basic URLs, leave
this None.
- :type trusted_signers: :class`boto.cloudfront.signers.TrustedSigners`
-
+
+ :type comment: str
:param default_root_object: Designates a default root object.
Only include a DefaultRootObject value
if you are going to assign a default
root object for the distribution.
- :type comment: str
+ :type logging: :class`boto.cloudfront.logging.LoggingInfo`
:param logging: Controls whether access logs are written for the
distribution. If you want to turn on access logs,
this should contain a LoggingInfo object; otherwise
it should contain None.
- :type logging: :class`boto.cloudfront.logging.LoggingInfo`
-
"""
self.connection = connection
self.origin = origin
@@ -173,6 +169,7 @@ def endElement(self, name, value, connection):
else:
setattr(self, name, value)
+
class StreamingDistributionConfig(DistributionConfig):
def __init__(self, connection=None, origin='', enabled=False,
@@ -184,6 +181,7 @@ def __init__(self, connection=None, origin='', enabled=False,
cnames=cnames, comment=comment,
trusted_signers=trusted_signers,
logging=logging)
+
def to_xml(self):
s = '<?xml version="1.0" encoding="UTF-8"?>\n'
s += '<StreamingDistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-07-15/">\n'
@@ -216,6 +214,7 @@ def to_xml(self):
s += '</StreamingDistributionConfig>\n'
return s
+
class DistributionSummary:
def __init__(self, connection=None, domain_name='', id='',
@@ -276,11 +275,13 @@ def endElement(self, name, value, connection):
def get_distribution(self):
return self.connection.get_distribution_info(self.id)
+
class StreamingDistributionSummary(DistributionSummary):
def get_distribution(self):
return self.connection.get_streaming_distribution_info(self.id)
-
+
+
class Distribution:
def __init__(self, connection=None, config=None, domain_name='',
@@ -348,7 +349,8 @@ def update(self, enabled=None, cnames=None, comment=None):
"""
new_config = DistributionConfig(self.connection, self.config.origin,
- self.config.enabled, self.config.caller_reference,
+ self.config.enabled,
+ self.config.caller_reference,
self.config.cnames, self.config.comment,
self.config.trusted_signers,
self.config.default_root_object)
@@ -358,7 +360,8 @@ def update(self, enabled=None, cnames=None, comment=None):
new_config.cnames = cnames
if comment != None:
new_config.comment = comment
- self.etag = self.connection.set_distribution_config(self.id, self.etag, new_config)
+ self.etag = self.connection.set_distribution_config(self.id, self.etag,
+ new_config)
self.config = new_config
self._object_class = Object
@@ -402,11 +405,11 @@ def _get_bucket(self):
return self._bucket
else:
raise NotImplementedError('Unable to get_objects on CustomOrigin')
-
+
def get_objects(self):
"""
Return a list of all content objects in this distribution.
-
+
:rtype: list of :class:`boto.cloudfront.object.Object`
:return: The content objects
"""
@@ -503,8 +506,8 @@ def create_signed_url(self, url, keypair_id,
ip_address=None, policy_url=None,
private_key_file=None, private_key_string=None):
"""
- Creates a signed CloudFront URL that is only valid within the specified
- parameters.
+ Creates a signed CloudFront URL that is only valid within the
+ specified parameters.
:type url: str
:param url: The URL of the protected object.
@@ -516,8 +519,8 @@ def create_signed_url(self, url, keypair_id,
:type expire_time: int
:param expire_time: The expiry time of the URL. If provided, the URL
- will expire after the time has passed. If not provided the URL will
- never expire. Format is a unix epoch.
+ will expire after the time has passed. If not provided the URL
+ will never expire. Format is a unix epoch.
Use time.time() + duration_in_sec.
:type valid_after_time: int
@@ -599,7 +602,8 @@ def _create_signing_params(self, url, keypair_id,
encoded_policy = self._url_base64_encode(policy)
params["Policy"] = encoded_policy
#sign the policy
- signature = self._sign_string(policy, private_key_file, private_key_string)
+ signature = self._sign_string(policy, private_key_file,
+ private_key_string)
#now base64 encode the signature (URL safe as well)
encoded_signature = self._url_base64_encode(signature)
params["Signature"] = encoded_signature
@@ -617,7 +621,8 @@ def _canned_policy(resource, expires):
return policy
@staticmethod
- def _custom_policy(resource, expires=None, valid_after=None, ip_address=None):
+ def _custom_policy(resource, expires=None, valid_after=None,
+ ip_address=None):
"""
Creates a custom policy string based on the supplied parameters.
"""
@@ -633,7 +638,7 @@ def _custom_policy(resource, expires=None, valid_after=None, ip_address=None):
policy = {"Statement": [{
"Resource": resource,
"Condition": condition}]}
- return json.dumps(policy, separators=(",", ":"))
+ return compat.json.dumps(policy, separators=(",", ":"))
@staticmethod
def _sign_string(message, private_key_file=None, private_key_string=None):
@@ -678,6 +683,7 @@ def _url_base64_encode(msg):
msg_base64 = msg_base64.replace('/', '~')
return msg_base64
+
class StreamingDistribution(Distribution):
def __init__(self, connection=None, config=None, domain_name='',
@@ -741,5 +747,3 @@ def update(self, enabled=None, cnames=None, comment=None):
def delete(self):
self.connection.delete_streaming_distribution(self.id, self.etag)
-
-
View
3  boto/cloudfront/exception.py
@@ -14,13 +14,14 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,4
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
from boto.exception import BotoServerError
+
class CloudFrontServerError(BotoServerError):
pass
View
19 boto/cloudfront/identity.py
@@ -14,13 +14,14 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
import uuid
+
class OriginAccessIdentity:
def __init__(self, connection=None, config=None, id='',
@@ -31,7 +32,7 @@ def __init__(self, connection=None, config=None, id='',
self.s3_user_id = s3_user_id
self.comment = comment
self.etag = None
-
+
def startElement(self, name, attrs, connection):
if name == 'CloudFrontOriginAccessIdentityConfig':
self.config = OriginAccessIdentityConfig()
@@ -55,15 +56,19 @@ def update(self, comment=None):
self.config.comment)
if comment != None:
new_config.comment = comment
- self.etag = self.connection.set_origin_identity_config(self.id, self.etag, new_config)
+ self.etag = self.connection.set_origin_identity_config(self.id,
+ self.etag,
+ new_config)
self.config = new_config
def delete(self):
- return self.connection.delete_origin_access_identity(self.id, self.etag)
+ return self.connection.delete_origin_access_identity(self.id,
+ self.etag)
def uri(self):
return 'origin-access-identity/cloudfront/%s' % self.id
-
+
+
class OriginAccessIdentityConfig:
def __init__(self, connection=None, caller_reference='', comment=''):
@@ -94,6 +99,7 @@ def endElement(self, name, value, connection):
else:
setattr(self, name, value)
+
class OriginAccessIdentitySummary:
def __init__(self, connection=None, id='',
@@ -103,7 +109,7 @@ def __init__(self, connection=None, id='',
self.s3_user_id = s3_user_id
self.comment = comment
self.etag = None
-
+
def startElement(self, name, attrs, connection):
return None
@@ -119,4 +125,3 @@ def endElement(self, name, value, connection):
def get_origin_access_identity(self):
return self.connection.get_origin_access_identity_info(self.id)
-
View
13 boto/cloudfront/invalidation.py
@@ -14,7 +14,7 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
@@ -22,12 +22,14 @@
import uuid
import urllib
+
class InvalidationBatch(object):
"""A simple invalidation request.
- :see: http://docs.amazonwebservices.com/AmazonCloudFront/2010-08-01/APIReference/index.html?InvalidationBatchDatatype.html
+ :see: http://goo.gl/fICmz
"""
- def __init__(self, paths=None, connection=None, distribution=None, caller_reference=''):
+ def __init__(self, paths=None, connection=None, distribution=None,
+ caller_reference=''):
"""Create a new invalidation request:
:paths: An array of paths to invalidate
"""
@@ -62,7 +64,10 @@ def __setitem__(self, k, v):
self.paths[k] = v
def escape(self, p):
- """Escape a path, make sure it begins with a slash and contains no invalid characters"""
+ """
+ Escape a path, make sure it begins with a slash and contains
+ no invalid characters
+ """
if not p[0] == "/":
p = "/%s" % p
return urllib.quote(p)
View
6 boto/cloudfront/logging.py
@@ -14,17 +14,18 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+
class LoggingInfo(object):
def __init__(self, bucket='', prefix=''):
self.bucket = bucket
self.prefix = prefix
-
+
def startElement(self, name, attrs, connection):
return None
@@ -35,4 +36,3 @@ def endElement(self, name, value, connection):
self.prefix = value
else:
setattr(self, name, value)
-
View
6 boto/cloudfront/object.py
@@ -14,13 +14,14 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
from boto.s3.key import Key
+
class Object(Key):
def __init__(self, bucket, name=None):
@@ -40,9 +41,8 @@ def url(self, scheme='http'):
url += self.name
return url
+
class StreamingObject(Object):
def url(self, scheme='rtmp'):
return Object.url(self, scheme)
-
-
View
59 boto/cloudfront/origin.py
@@ -15,19 +15,21 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
from .identity import OriginAccessIdentity
+
def get_oai_value(origin_access_identity):
if isinstance(origin_access_identity, OriginAccessIdentity):
return origin_access_identity.uri()
else:
return origin_access_identity
-
+
+
class S3Origin(object):
"""
Origin information to associate with the distribution.
@@ -37,20 +39,17 @@ class S3Origin(object):
def __init__(self, dns_name=None, origin_access_identity=None):
"""
- :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.
+ :param dns_name: The DNS name of your Amazon S3 bucket to
+ associate with the distribution. For example:
+ mybucket.s3.amazonaws.com.
+
:type origin_access_identity: 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.
"""
self.dns_name = dns_name
self.origin_access_identity = origin_access_identity
@@ -77,7 +76,8 @@ def to_xml(self):
s += ' <OriginAccessIdentity>%s</OriginAccessIdentity>\n' % val
s += ' </S3Origin>\n'
return s
-
+
+
class CustomOrigin(object):
"""
Origin information to associate with the distribution.
@@ -88,27 +88,23 @@ class CustomOrigin(object):
def __init__(self, dns_name=None, http_port=80, https_port=443,
origin_protocol_policy=None):
"""
- :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 dns_name: The DNS name of your Amazon S3 bucket to
+ associate with the distribution. For example:
+ mybucket.s3.amazonaws.com.
+
+ :type http_port: int
: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
-
+ :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.
"""
self.dns_name = dns_name
self.http_port = http_port
@@ -147,4 +143,3 @@ def to_xml(self):
s += ' <OriginProtocolPolicy>%s</OriginProtocolPolicy>\n' % self.origin_protocol_policy
s += ' </CustomOrigin>\n'
return s
-
View
10 boto/cloudfront/signers.py
@@ -14,17 +14,18 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+
class Signer:
def __init__(self):
self.id = None
self.key_pair_ids = []
-
+
def startElement(self, name, attrs, connection):
return None
@@ -35,7 +36,8 @@ def endElement(self, name, value, connection):
self.id = value
elif name == 'KeyPairId':
self.key_pair_ids.append(value)
-
+
+
class ActiveTrustedSigners(list):
def startElement(self, name, attrs, connection):
@@ -47,6 +49,7 @@ def startElement(self, name, attrs, connection):
def endElement(self, name, value, connection):
pass
+
class TrustedSigners(list):
def startElement(self, name, attrs, connection):
@@ -57,4 +60,3 @@ def endElement(self, name, value, connection):
self.append(name)
elif name == 'AwsAccountNumber':
self.append(value)
-
Please sign in to comment.
Something went wrong with that request. Please try again.