Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some tweaks to the CloudFront module.

  • Loading branch information...
commit 93ce30cb0a5c02c8d5c0b580789bd822b67fa0b9 1 parent 1aec0ad
Mitch.Garnaat authored
Showing with 27 additions and 6 deletions.
  1. +21 −6 boto/cloudfront/distribution.py
  2. +6 −0 boto/cloudfront/object.py
View
27 boto/cloudfront/distribution.py
@@ -21,7 +21,7 @@
import uuid
from boto.cloudfront.identity import OriginAccessIdentity
-from boto.cloudfront.object import Object
+from boto.cloudfront.object import Object, StreamingObject
from boto.cloudfront.signers import Signer, ActiveTrustedSigners, TrustedSigners
from boto.cloudfront.logging import LoggingInfo
from boto.s3.acl import ACL
@@ -240,7 +240,8 @@ def endElement(self, name, value, connection):
setattr(self, name, value)
def update(self, enabled=None, cnames=None, comment=None,
- origin_access_identity=None):
+ origin_access_identity=None,
+ trusted_signers=None):
"""
Update the configuration of the Distribution.
@@ -260,11 +261,16 @@ def update(self, enabled=None, cnames=None, comment=None,
must be provided if you want the
distribution to serve private content.
+ :type trusted_signers: :class:`boto.cloudfront.signers.TrustedSigner`
+ :param trusted_signers: The AWS users who are authorized to sign
+ URL's for private content in this Distribution.
+
"""
new_config = DistributionConfig(self.connection, self.config.origin,
self.config.enabled, self.config.caller_reference,
self.config.cnames, self.config.comment,
- self.config.origin_access_identity)
+ self.config.origin_access_identity,
+ self.config.trusted_signers)
if enabled != None:
new_config.enabled = enabled
if cnames != None:
@@ -273,8 +279,11 @@ def update(self, enabled=None, cnames=None, comment=None,
new_config.comment = comment
if origin_access_identity != None:
new_config.origin_access_identity = origin_access_identity
+ if trusted_signers:
+ new_config.trusted_signers = trusted_signers
self.etag = self.connection.set_distribution_config(self.id, self.etag, new_config)
self.config = new_config
+ self._object_class = Object
def enable(self):
"""
@@ -310,7 +319,7 @@ def _get_bucket(self):
proxy_pass=self.connection.proxy_pass)
self._bucket = s3.get_bucket(bucket_name)
self._bucket.distribution = self
- self._bucket.set_key_class(Object)
+ self._bucket.set_key_class(self._object_class)
return self._bucket
def get_objects(self):
@@ -374,7 +383,7 @@ def set_permissions_all(self, replace=False):
for key in bucket:
self.set_permissions(key)
- def add_object(self, name, content, headers=None):
+ def add_object(self, name, content, headers=None, replace=True):
"""
Adds a new content object to the Distribution. The content
for the object will be copied to a new Key in the S3 Bucket
@@ -404,11 +413,17 @@ def add_object(self, name, content, headers=None):
object = bucket.new_key(name)
object.set_contents_from_file(content, headers=headers, policy=policy)
if self.config.origin_access_identity:
- self.set_permissions(object, True)
+ self.set_permissions(object, replace)
return object
class StreamingDistribution(Distribution):
+ def __init__(self, connection=None, config=None, domain_name='',
+ id='', last_modified_time=None, status=''):
+ Distribution.__init__(self, connection, config, domain_name,
+ id, last_modified_time, status)
+ self._object_class = StreamingObject
+
def startElement(self, name, attrs, connection):
if name == 'StreamingDistributionConfig':
self.config = StreamingDistributionConfig()
View
6 boto/cloudfront/object.py
@@ -39,4 +39,10 @@ def url(self, scheme='http'):
url += '/'
url += self.name
return url
+
+class StreamingObject(Object):
+
+ def url(self, scheme='rtmp'):
+ return Object.url(self, scheme)
+
Please sign in to comment.
Something went wrong with that request. Please try again.