summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Garnaat <mitch@garnaat.com>2012-03-27 19:49:46 -0700
committerMitch Garnaat <mitch@garnaat.com>2012-03-27 19:49:46 -0700
commit7f4fe40eda8b0ad1c58b647f95bbdaecf2506ffd (patch)
tree1bb86f075b622eb9836b7325d4e736f24c169576
parent3e66569fb9345c10ed6ed057689f924d415a1000 (diff)
downloadboto-7f4fe40eda8b0ad1c58b647f95bbdaecf2506ffd.tar.gz
PEP8 and pyflakes cleanup.
-rw-r--r--boto/cloudfront/__init__.py96
-rw-r--r--boto/cloudfront/distribution.py74
-rw-r--r--boto/cloudfront/exception.py3
-rw-r--r--boto/cloudfront/identity.py19
-rw-r--r--boto/cloudfront/invalidation.py13
-rw-r--r--boto/cloudfront/logging.py6
-rw-r--r--boto/cloudfront/object.py6
-rw-r--r--boto/cloudfront/origin.py59
-rw-r--r--boto/cloudfront/signers.py10
9 files changed, 154 insertions, 132 deletions
diff --git a/boto/cloudfront/__init__.py b/boto/cloudfront/__init__.py
index 7f98b70b..4f27f10c 100644
--- a/boto/cloudfront/__init__.py
+++ b/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 @@ class CloudFrontConnection(AWSAuthConnection):
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 @@ class CloudFrontConnection(AWSAuthConnection):
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 @@ class CloudFrontConnection(AWSAuthConnection):
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 @@ class CloudFrontConnection(AWSAuthConnection):
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 @@ class CloudFrontConnection(AWSAuthConnection):
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 @@ class CloudFrontConnection(AWSAuthConnection):
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 @@ class CloudFrontConnection(AWSAuthConnection):
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 @@ class CloudFrontConnection(AWSAuthConnection):
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 @@ class CloudFrontConnection(AWSAuthConnection):
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 @@ class CloudFrontConnection(AWSAuthConnection):
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 @@ class CloudFrontConnection(AWSAuthConnection):
return paths
else:
raise CloudFrontServerError(response.status, response.reason, body)
-
-
diff --git a/boto/cloudfront/distribution.py b/boto/cloudfront/distribution.py
index 3d59cd79..9dff2d1b 100644
--- a/boto/cloudfront/distribution.py
+++ b/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 @@ class DistributionConfig:
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 @@ class DistributionConfig:
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 @@ class DistributionConfig:
else:
setattr(self, name, value)
+
class StreamingDistributionConfig(DistributionConfig):
def __init__(self, connection=None, origin='', enabled=False,
@@ -184,6 +181,7 @@ class StreamingDistributionConfig(DistributionConfig):
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 @@ class StreamingDistributionConfig(DistributionConfig):
s += '</StreamingDistributionConfig>\n'
return s
+
class DistributionSummary:
def __init__(self, connection=None, domain_name='', id='',
@@ -276,11 +275,13 @@ class DistributionSummary:
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 @@ class Distribution:
"""
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 @@ class Distribution:
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 @@ class Distribution:
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 @@ class Distribution:
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 @@ class Distribution:
: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 @@ class Distribution:
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 @@ class Distribution:
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 @@ class Distribution:
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 @@ class Distribution:
msg_base64 = msg_base64.replace('/', '~')
return msg_base64
+
class StreamingDistribution(Distribution):
def __init__(self, connection=None, config=None, domain_name='',
@@ -741,5 +747,3 @@ class StreamingDistribution(Distribution):
def delete(self):
self.connection.delete_streaming_distribution(self.id, self.etag)
-
-
diff --git a/boto/cloudfront/exception.py b/boto/cloudfront/exception.py
index 76806421..7312ca21 100644
--- a/boto/cloudfront/exception.py
+++ b/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
diff --git a/boto/cloudfront/identity.py b/boto/cloudfront/identity.py
index 1571e87a..59661c08 100644
--- a/boto/cloudfront/identity.py
+++ b/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 @@ class OriginAccessIdentity:
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 @@ class OriginAccessIdentity:
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 @@ class OriginAccessIdentityConfig:
else:
setattr(self, name, value)
+
class OriginAccessIdentitySummary:
def __init__(self, connection=None, id='',
@@ -103,7 +109,7 @@ class OriginAccessIdentitySummary:
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 @@ class OriginAccessIdentitySummary:
def get_origin_access_identity(self):
return self.connection.get_origin_access_identity_info(self.id)
-
diff --git a/boto/cloudfront/invalidation.py b/boto/cloudfront/invalidation.py
index b213e65c..75ea71a5 100644
--- a/boto/cloudfront/invalidation.py
+++ b/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 @@ class InvalidationBatch(object):
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)
diff --git a/boto/cloudfront/logging.py b/boto/cloudfront/logging.py
index 6c2f4fde..80d25dde 100644
--- a/boto/cloudfront/logging.py
+++ b/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 @@ class LoggingInfo(object):
self.prefix = value
else:
setattr(self, name, value)
-
diff --git a/boto/cloudfront/object.py b/boto/cloudfront/object.py
index 3574d136..f5fdc3f1 100644
--- a/boto/cloudfront/object.py
+++ b/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 @@ class Object(Key):
url += self.name
return url
+
class StreamingObject(Object):
def url(self, scheme='rtmp'):
return Object.url(self, scheme)
-
-
diff --git a/boto/cloudfront/origin.py b/boto/cloudfront/origin.py
index 95ec0d8a..5bd5d9e2 100644
--- a/boto/cloudfront/origin.py
+++ b/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 @@ class S3Origin(object):
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 @@ class CustomOrigin(object):
s += ' <OriginProtocolPolicy>%s</OriginProtocolPolicy>\n' % self.origin_protocol_policy
s += ' </CustomOrigin>\n'
return s
-
diff --git a/boto/cloudfront/signers.py b/boto/cloudfront/signers.py
index 0b0cd50a..8fd54c1f 100644
--- a/boto/cloudfront/signers.py
+++ b/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 @@ class Signer:
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 @@ class ActiveTrustedSigners(list):
def endElement(self, name, value, connection):
pass
+
class TrustedSigners(list):
def startElement(self, name, attrs, connection):
@@ -57,4 +60,3 @@ class TrustedSigners(list):
self.append(name)
elif name == 'AwsAccountNumber':
self.append(value)
-