comparison frontends/src/jp/cmd_pubsub.py @ 2204:afc703419186

jp (pubsub): added affiliations and node/affiliations/get: affiliations allow to retrieve all node were a profile is affiliated on a service, or the affiliation on a specific node. node/affiliations/get is for node owner and allow to retrieve who is affiliated with a node and which kind of affiliation.
author Goffi <goffi@goffi.org>
date Thu, 23 Mar 2017 21:04:01 +0100
parents ea0d0a4e2ad8
children d662bdd682b2
comparison
equal deleted inserted replaced
2203:427391c706eb 2204:afc703419186
99 self.profile, 99 self.profile,
100 callback=self.psNodeConfigurationSetCb, 100 callback=self.psNodeConfigurationSetCb,
101 errback=self.psNodeConfigurationSetEb) 101 errback=self.psNodeConfigurationSetEb)
102 102
103 103
104 class NodeAffiliationsGet(base.CommandBase):
105
106 def __init__(self, host):
107 base.CommandBase.__init__(self, host, 'get', use_output=C.OUTPUT_DICT, help=_(u'retrieve node affiliations (for node owner)'))
108 self.need_loop=True
109
110 def add_parser_options(self):
111 self.parser.add_argument("node", type=base.unicode_decoder, help=_(u"node to request"))
112 self.parser.add_argument("-s", "--service", type=base.unicode_decoder, default=u'',
113 help=_(u"JID of the PubSub service (default: request profile own pubsub)"))
114
115 def psNodeAffiliationsGetCb(self, affiliations):
116 self.output(affiliations)
117 self.host.quit()
118
119 def psNodeAffiliationsGetEb(self, failure_):
120 self.disp(u"can't get node affiliations: {reason}".format(
121 reason=failure_), error=True)
122 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
123
124 def start(self):
125 self.host.bridge.psNodeAffiliationsGet(
126 self.args.service,
127 self.args.node,
128 self.profile,
129 callback=self.psNodeAffiliationsGetCb,
130 errback=self.psNodeAffiliationsGetEb)
131
132
133 class NodeAffiliations(base.CommandBase):
134 subcommands = (NodeAffiliationsGet,)
135
136 def __init__(self, host):
137 super(NodeAffiliations, self).__init__(host, 'affiliations', use_profile=False, help=_(u'set or retrieve node affiliations'))
138
139
104 class Node(base.CommandBase): 140 class Node(base.CommandBase):
105 subcommands = (NodeInfo, NodeSet) 141 subcommands = (NodeInfo, NodeSet, NodeAffiliations)
106 142
107 def __init__(self, host): 143 def __init__(self, host):
108 super(Node, self).__init__(host, 'node', use_profile=False, help=_('node handling')) 144 super(Node, self).__init__(host, 'node', use_profile=False, help=_('node handling'))
109 145
110 146
147 self.profile, 183 self.profile,
148 callback=self.psItemGetCb, 184 callback=self.psItemGetCb,
149 errback=self.psItemGetEb) 185 errback=self.psItemGetEb)
150 186
151 187
188 class Affiliations(base.CommandBase):
189
190 def __init__(self, host):
191 base.CommandBase.__init__(self, host, 'affiliations', use_output=C.OUTPUT_DICT, help=_(u'retrieve all affiliations on a service'))
192 self.need_loop=True
193
194 def add_parser_options(self):
195 self.parser.add_argument("-n", "--node", type=base.unicode_decoder, default=u'', help=_(u"node to request"))
196 self.parser.add_argument("-s", "--service", type=base.unicode_decoder, default=u'',
197 help=_(u"JID of the PubSub service (default: request profile own pubsub)"))
198
199 def psAffiliationsGetCb(self, affiliations):
200 self.output(affiliations)
201 self.host.quit()
202
203 def psAffiliationsGetEb(self, failure_):
204 self.disp(u"can't get node affiliations: {reason}".format(
205 reason=failure_), error=True)
206 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
207
208 def start(self):
209 self.host.bridge.psAffiliationsGet(
210 self.args.service,
211 self.args.node,
212 self.profile,
213 callback=self.psAffiliationsGetCb,
214 errback=self.psAffiliationsGetEb)
215
216
152 class Pubsub(base.CommandBase): 217 class Pubsub(base.CommandBase):
153 subcommands = (Get, Node) 218 subcommands = (Get, Node, Affiliations)
154 219
155 def __init__(self, host): 220 def __init__(self, host):
156 super(Pubsub, self).__init__(host, 'pubsub', use_profile=False, help=_('PubSub nodes/items management')) 221 super(Pubsub, self).__init__(host, 'pubsub', use_profile=False, help=_('PubSub nodes/items management'))