Package s3 :: Module objects :: Class S3Bucket
[hide private]
[frames] | no frames]

Class S3Bucket

source code


S3Bucket class

Behaves like a dictionary of keys in the bucket, with some additional methods.

Instance Methods [hide private]
  __init__(self, name, connection)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  _request(self, method='', obj=None, send_io=None, params=None, headers=None, *args)
  __str__(self)
str(x)
  __repr__(self)
repr(x)
S3Object get(self, key, headers={})
Get an S3Object from the bucket.
dict head(self, key, headers={})
Get an object's headers from bucket.
  list(self, prefix=None, marker=None, max_keys=None, delimiter=None)
List bucket objects.
  save(self, s3object, headers={})
Save an S3Object into bucket.
  delete(self, objects)
Delete an S3Object, a key or list of keys or objects from bucket.
  keys(self, prefix=None, marker=None, max_keys=None, delimiter=None)
Returns a flat list of object keys in bucket.
  values(self, prefix=None, marker=None, max_keys=None, delimiter=None)
List bucket objects.
list items(self)
Returns (key, value) pairs, where, keys are object names, and values are S3Objects.
  has_key(self, key)
Does key exists in bucket.
  __getitem__(self, key)
Get an S3Object from bucket.
  __delitem__(self, s3object)
Delete a key from bucket.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, name, connection)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

_request(self, method='', obj=None, send_io=None, params=None, headers=None, *args)

source code 
None

__str__(self)
(Informal representation operator)

source code 
str(x)
Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)

get(self, key, headers={})

source code 
Get an S3Object from the bucket.
Parameters:
  • key (string) - Key of the object
  • headers (dict) - Dictionary of additional headers
Returns: S3Object
Selected S3Object if found or None

head(self, key, headers={})

source code 
Get an object's headers from bucket.
Parameters:
  • key (string) - Key of the object
  • headers (dict) - Dictionary of additional headers
Returns: dict
Dictionary of object headers

list(self, prefix=None, marker=None, max_keys=None, delimiter=None)

source code 
List bucket objects.
Parameters:
  • prefix (string) - Limits the response to keys which begin with the indicated prefix. You can use prefixes to separate a bucket into different sets of keys in a way similar to how a file system uses folders.
  • marker (string) - Indicates where in the bucket to begin listing. The list will only include keys that occur lexicographically after marker. This is convenient for pagination: To get the next page of results use the last key of the current page as the marker.
  • max_keys (int) - The maximum number of keys you'd like to see in the response body. The server may return fewer than this many keys, but will not return more.
  • delimiter (char) - Causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be rolled up into a single result element in the CommonPrefixes collection. These rolled-up keys are not returned elsewhere in the response.

save(self, s3object, headers={})

source code 
Save an S3Object into bucket.
Parameters:
  • s3object (S3Object) - An S3Object that has to be saved
  • headers (dict) - Dictionary of additional headers

delete(self, objects)

source code 
Delete an S3Object, a key or list of keys or objects from bucket.
Parameters:
  • objects (S3Object, string, list of S3Objects or list of strings) - S3Object, S3Object key, or list of both to be deleted

keys(self, prefix=None, marker=None, max_keys=None, delimiter=None)

source code 
Returns a flat list of object keys in bucket.
Parameters:
  • prefix (string) - Limits the response to keys which begin with the indicated prefix. You can use prefixes to separate a bucket into different sets of keys in a way similar to how a file system uses folders.
  • marker (string) - Indicates where in the bucket to begin listing. The list will only include keys that occur lexicographically after marker. This is convenient for pagination: To get the next page of results use the last key of the current page as the marker.
  • max_keys (int) - The maximum number of keys you'd like to see in the response body. The server may return fewer than this many keys, but will not return more.
  • delimiter (char) - Causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be rolled up into a single result element in the CommonPrefixes collection. These rolled-up keys are not returned elsewhere in the response.

values(self, prefix=None, marker=None, max_keys=None, delimiter=None)

source code 
List bucket objects.
Parameters:
  • prefix (string) - Limits the response to keys which begin with the indicated prefix. You can use prefixes to separate a bucket into different sets of keys in a way similar to how a file system uses folders.
  • marker (string) - Indicates where in the bucket to begin listing. The list will only include keys that occur lexicographically after marker. This is convenient for pagination: To get the next page of results use the last key of the current page as the marker.
  • max_keys (int) - The maximum number of keys you'd like to see in the response body. The server may return fewer than this many keys, but will not return more.
  • delimiter (char) - Causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be rolled up into a single result element in the CommonPrefixes collection. These rolled-up keys are not returned elsewhere in the response.

items(self)

source code 
Returns (key, value) pairs, where, keys are object names, and values are S3Objects.
Returns: list
List of (bucket name, bucket) pairs

has_key(self, key)

source code 
Does key exists in bucket.

__getitem__(self, key)
(Indexing operator)

source code 
Get an S3Object from bucket.

__delitem__(self, s3object)
(Index deletion operator)

source code 
Delete a key from bucket.