1
# canonical.ubuntuone.storage.syncdaemon.interfaces - ActionQueue interface
3
# Authors: John Lenton <john.lenton@canonical.com>
4
# Lucio Torre <lucio.torre@canonical.com>
6
# Copyright 2009 Canonical Ltd.
8
# This program is free software: you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License version 3, as published
10
# by the Free Software Foundation.
12
# This program is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranties of
14
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15
# PURPOSE. See the GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License along
18
# with this program. If not, see <http://www.gnu.org/licenses/>.
20
This is the interface of the ActionQueue
23
from zope.interface import Interface, Attribute
25
# pylint: disable-msg=W0232,E0213,E0211
27
class IContentQueue(Interface):
29
The content queue is the part of access queue that manages uploads
30
and downloads of content.
33
downloading = Attribute("The set of active downloads")
34
uploading = Attribute("The set of active uploads")
36
def cancel_download(share_id, node_id):
38
Try to cancel any download for the given node.
40
The return value is whether we've been able to cancel a
44
def cancel_upload(share_id, node_id):
46
Try to cancel any upload for the given node.
48
The return value is whether we're sure that we've been able to
49
cancel an upload. We might succeed without knowing it,
53
def download(share_id, node_id, server_hash, fileobj):
55
Go get the content for the given node and dump it into
56
file-like object fileobj.
59
def upload(share_id, node_id, previous_hash, hash, crc32,
60
size, deflated_size, fileobj):
62
Put the content of file-like object fileobj up in the given
66
class IMetaQueue(Interface):
68
The MetaQueue is the part of AccessQueue that manages transfers of
72
def make_file(share_id, parent_id, name, marker):
74
Ask the server to create a file called name in the given
75
parent; and use marker as a marker in the ensuing
79
def make_dir(share_id, parent_id, name, marker):
81
Ask the server to make a directory called name in the given
82
parent, and use marker as a marker in the ensuing
86
def move(share_id, node_id, old_parent_id, new_parent_id, new_name):
88
Ask the server to move a node to the given parent and name.
91
def unlink(share_id, parent_id, node_id):
93
Unlink the given node.
98
Gossip with the server about the freshness of the server hashes
100
Items is a list of (hash_id, node_id, node_hash).
103
def listdir(share_id, node_id, server_hash, fileobj):
105
List (get the content of) the given directory.
110
Get a list of the shares, and put the result on the event queue.
113
def create_share(node, share_to, name, access_level):
115
Ask the server to create a share.
118
class IActionQueue(IContentQueue, IMetaQueue):
120
The access queue itself.
122
connection_state = Attribute('The connection state')
124
def connect(host, port, use_ssl=False):
126
Open a (possibly SSL) connection to the API server on (host,
127
port). Once you've connected, do the OAuth dance.
135
class IMarker(Interface):
137
A marker interface for telling server uuids apart from markers.