Buckets and Files

Manage buckets and files on the server.

class renga.models.storage.BucketCollection(client=None)[source]

Represent storage buckets on the server.

Create a representation of objects on the server.

class Meta[source]

Information about individual buckets.

model

alias of Bucket

backends

Return a list of the enabled backends.

create(name=None, backend='local', **kwargs)[source]

Create a new Bucket instance.

list()

Return a list if the collection is iterable.

Bucket objects

class renga.models.storage.Bucket[source]

Represent a storage bucket.

Create a representation of an object on the server.

backend

The backend of this bucket.

files

The FileCollection instance.

id

The identifier of the object.

name

The bucket name.

Files

Manage files in the bucket.

class renga.models.storage.FileCollection(bucket, **kwargs)[source]

Represent files in a bucket on the server.

Initialize collection of files in the bucket.

class Meta[source]

Information about individual files.

model

alias of File

create(filename=None)[source]

Create an empty file in this bucket.

from_url(url, filename=None)[source]

Create a file with data from the streamed GET response.

Example

>>> file_ = client.buckets[1234].files.from_url(
...     'https://example.com/tests/data', filename='hello')
>>> file_.id
9876
>>> client.buckets[1234].files[9876].open('r').read()
b'hello world'
list()

Return a list if the collection is iterable.

open(filename=None, mode='w')[source]

Create an empty file in this bucket.

File objects

class renga.models.storage.File[source]

Represent a file object.

Create a representation of an object on the server.

access_token

The access token for performing file operations.

clone(filename=None)[source]

Create an instance of the file for independent version tracking.

filename

Filename of the file.

id

The identifier of the object.

open(mode='r')

Return the FileHandle instance.

versions

An object for managing file versions.

Returns:The collection of file versions.
Return type:renga.models.storage.FileVersionCollection

File handle objects

class renga.models.storage.FileHandle[source]

An object exposing a pythonic file-oriented API.

Depending on the bucket to which it belongs to, a file object can mediate access to different storage backends (local, Swift, etc).

Create a representation of an object on the server.

can_read

Check if the file handle is readable.

can_write

Check if the file handle is writable.

from_url(url)[source]

Write data from the streamed GET response from the given URL.

Example

>>> with client.buckets[1234].files[9876].open('w') as fp:
...     fp.from_url('https://example.com/tests/data')
id

The identifier of the object.

read(*args, **kwargs)[source]

Read data from the file.

write(data)[source]

Write data to the file.

File versions

class renga.models.storage.FileVersionCollection(file_, **kwargs)[source]

Represent file versions of a file stored on the server.

Initialize a collection of file versions.

class Meta[source]

Information about individual file versions.

model

alias of FileVersion

list()

Return a list if the collection is iterable.

class renga.models.storage.FileVersion(response=None, client=None, collection=None)[source]

Represent a file version object.

Create a representation of an object on the server.

created

Return file creation date and time.

filename

Filename of the file.

id

The identifier of the object.

open(mode='r')

Return the FileHandle instance.