Index: boto/gs/bucket.py |
diff --git a/boto/gs/bucket.py b/boto/gs/bucket.py |
index b4b80e812620bde1a653d90a0a289320e1c9223b..f49533c73f372cd4f2af8f9d888c792697f8fce8 100644 |
--- a/boto/gs/bucket.py |
+++ b/boto/gs/bucket.py |
@@ -22,7 +22,7 @@ |
import boto |
from boto import handler |
from boto.exception import InvalidAclError |
-from boto.gs.acl import ACL |
+from boto.gs.acl import ACL, CannedACLStrings |
from boto.gs.acl import SupportedPermissions as GSPermissions |
from boto.gs.key import Key as GSKey |
from boto.s3.acl import Policy |
@@ -55,6 +55,25 @@ class Bucket(S3Bucket): |
raise self.connection.provider.storage_response_error( |
response.status, response.reason, body) |
+ def set_canned_acl(self, acl_str, key_name='', headers=None, |
+ version_id=None): |
+ assert acl_str in CannedACLStrings |
+ |
+ if headers: |
+ headers[self.connection.provider.acl_header] = acl_str |
+ else: |
+ headers={self.connection.provider.acl_header: acl_str} |
+ |
+ query_args='acl' |
+ if version_id: |
+ query_args += '&versionId=%s' % version_id |
+ response = self.connection.make_request('PUT', self.name, key_name, |
+ headers=headers, query_args=query_args) |
+ body = response.read() |
+ if response.status != 200: |
+ raise self.connection.provider.storage_response_error( |
+ response.status, response.reason, body) |
+ |
# Method with same signature as boto.s3.bucket.Bucket.add_email_grant(), |
# to allow polymorphic treatment at application layer. |
def add_email_grant(self, permission, email_address, |
@@ -171,3 +190,23 @@ class Bucket(S3Bucket): |
def list_grants(self, headers=None): |
acl = self.get_acl(headers=headers) |
return acl.entries |
+ |
+ def disable_logging(self, headers=None): |
+ xml_str = '<?xml version="1.0" encoding="UTF-8"?><Logging/>' |
+ self.set_subresource('logging', xml_str, headers=headers) |
+ |
+ def enable_logging(self, target_bucket, target_prefix=None, headers=None, |
+ canned_acl=None): |
+ if isinstance(target_bucket, Bucket): |
+ target_bucket = target_bucket.name |
+ xml_str = '<?xml version="1.0" encoding="UTF-8"?><Logging>' |
+ xml_str = (xml_str + '<LogBucket>%s</LogBucket>' % target_bucket) |
+ if target_prefix: |
+ xml_str = (xml_str + |
+ '<LogObjectPrefix>%s</LogObjectPrefix>' % target_prefix) |
+ if canned_acl: |
+ xml_str = (xml_str + |
+ '<PredefinedAcl>%s</PredefinedAcl>' % canned_acl) |
+ xml_str = xml_str + '</Logging>' |
+ |
+ self.set_subresource('logging', xml_str, headers=headers) |