107
|
1 from zope.interface import Interface |
111
|
2 from twisted.words.protocols.jabber import jid |
107
|
3 |
|
4 class Error(Exception): |
|
5 msg = None |
|
6 |
|
7 class NodeNotFound(Error): |
|
8 pass |
|
9 |
|
10 |
|
11 class NodeExists(Error): |
|
12 pass |
|
13 |
|
14 |
|
15 class IStorage(Interface): |
111
|
16 """ Storage interface """ |
107
|
17 |
|
18 def get_node(self, node_id): |
111
|
19 """ Get Node. |
|
20 |
|
21 @param node_id: NodeID of the desired node. |
|
22 @type node_id: L{str} |
|
23 @return: deferred that returns a L{Node} object. |
|
24 """ |
107
|
25 |
|
26 def get_node_ids(self): |
111
|
27 """ Return all NodeIDs. |
|
28 |
|
29 @return: deferred that returns a list of NodeIDs (L{str}). |
|
30 """ |
107
|
31 |
|
32 def create_node(self, node_id, owner, config = None, type='leaf'): |
111
|
33 """ Create new node. |
|
34 |
|
35 The implementation should make sure, the passed owner JID is stripped |
|
36 of the resource (e.g. using C{owner.userhostJID()}). |
|
37 |
|
38 @param node_id: NodeID of the new node. |
|
39 @type node_id: L{str} |
|
40 @param owner: JID of the new nodes's owner. |
|
41 @type owner: L{jid.JID} |
|
42 @param config: Configuration |
|
43 @param type: Node type. Can be either C{'leaf'} or C{'collection'}. |
|
44 @return: deferred that fires on creation. |
|
45 """ |
107
|
46 |
|
47 def delete_node(self, node_id): |
111
|
48 """ Delete a node. |
|
49 |
|
50 @param node_id: NodeID of the new node. |
|
51 @type node_id: L{str} |
|
52 @return: deferred that fires on deletion. |
|
53 """ |
107
|
54 |
|
55 def get_affiliations(self, entity): |
111
|
56 """ Get all affiliations for entity. |
|
57 |
|
58 The implementation should make sure, the passed owner JID is stripped |
|
59 of the resource (e.g. using C{owner.userhostJID()}). |
|
60 |
|
61 @param entity: JID of the entity. |
|
62 @type entity: L{jid.JID} |
|
63 @return: deferred that returns a L{list} of tuples of the form |
|
64 C{(node_id, affiliation)}, where C{node_id} is of the type |
|
65 L{str} and C{affiliation} is one of C{'owner'}, C{'publisher'} |
|
66 and C{'outcast'}. |
|
67 """ |
107
|
68 |
|
69 def get_subscriptions(self, entity): |
111
|
70 """ Get all subscriptions for an entity. |
|
71 |
|
72 The implementation should make sure, the passed owner JID is stripped |
|
73 of the resource (e.g. using C{owner.userhostJID()}). |
|
74 |
|
75 @param entity: JID of the entity. |
|
76 @type entity: L{jid.JID} |
|
77 @return: deferred that returns a L{list} of tuples of the form |
|
78 C{(node_id, subscriber, state)}, where C{node_id} is of the |
|
79 type L{str}, C{subscriber} of the type {jid.JID}, and |
|
80 C{state} is C{'subscribed'} or C{'pending'}. |
|
81 """ |
107
|
82 |
|
83 |
|
84 class INode(Interface): |
|
85 """ """ |
|
86 def get_type(self): |
116
|
87 """ Get node's type. |
|
88 |
|
89 @return: C{'leaf'} or C{'collection'}. |
|
90 """ |
107
|
91 |
|
92 def get_configuration(self): |
116
|
93 """ Get node's configuration. |
|
94 |
|
95 The configuration must at least have two options: |
|
96 C{pubsub#persist_items}, and C{pubsub#deliver_payloads}. |
|
97 |
|
98 @return: L{dict} of configuration options. |
|
99 """ |
107
|
100 |
|
101 def get_meta_data(self): |
116
|
102 """ Get node's meta data. |
|
103 |
|
104 The meta data must be a superset of the configuration options, and |
|
105 also at least should have a C{pubsub#node_type} entry. |
|
106 |
|
107 @return: L{dict} of meta data. |
|
108 """ |
107
|
109 |
|
110 def set_configuration(self, options): |
|
111 """ """ |
|
112 |
|
113 def get_affiliation(self, entity): |
|
114 """ """ |
|
115 |
|
116 def add_subscription(self, subscriber, state): |
|
117 """ """ |
|
118 |
|
119 def remove_subscription(self, subscriber): |
|
120 """ """ |
|
121 |
|
122 def get_subscribers(self): |
|
123 """ """ |
|
124 |
|
125 def is_subscribed(self, subscriber): |
|
126 """ """ |
|
127 |
|
128 |
|
129 class ILeafNode(Interface): |
|
130 """ """ |
|
131 def store_items(self, items, publisher): |
|
132 """ """ |
|
133 |
|
134 def remove_items(self, item_ids): |
|
135 """ """ |
|
136 |
|
137 def get_items(self, max_items=None): |
|
138 """ """ |
|
139 |
|
140 def get_items_by_id(self, item_ids): |
|
141 """ """ |
|
142 |
|
143 def purge(self): |
|
144 """ """ |
|
145 |
|
146 |
|
147 class ISubscription(Interface): |
|
148 """ """ |