Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1022)

Unified Diff: boto/gs/bucket.py

Issue 8386013: Merging in latest boto. (Closed) Base URL: svn://svn.chromium.org/boto
Patch Set: Redoing vendor drop by deleting and then merging. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « boto/gs/acl.py ('k') | boto/gs/connection.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « boto/gs/acl.py ('k') | boto/gs/connection.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698