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.
This commit is contained in:
Goffi 2017-03-23 21:04:01 +01:00
commit 281c514ae4

View file

@ -101,8 +101,44 @@ class NodeSet(base.CommandBase):
errback=self.psNodeConfigurationSetEb)
class NodeAffiliationsGet(base.CommandBase):
def __init__(self, host):
base.CommandBase.__init__(self, host, 'get', use_output=C.OUTPUT_DICT, help=_(u'retrieve node affiliations (for node owner)'))
self.need_loop=True
def add_parser_options(self):
self.parser.add_argument("node", type=base.unicode_decoder, help=_(u"node to request"))
self.parser.add_argument("-s", "--service", type=base.unicode_decoder, default=u'',
help=_(u"JID of the PubSub service (default: request profile own pubsub)"))
def psNodeAffiliationsGetCb(self, affiliations):
self.output(affiliations)
self.host.quit()
def psNodeAffiliationsGetEb(self, failure_):
self.disp(u"can't get node affiliations: {reason}".format(
reason=failure_), error=True)
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
def start(self):
self.host.bridge.psNodeAffiliationsGet(
self.args.service,
self.args.node,
self.profile,
callback=self.psNodeAffiliationsGetCb,
errback=self.psNodeAffiliationsGetEb)
class NodeAffiliations(base.CommandBase):
subcommands = (NodeAffiliationsGet,)
def __init__(self, host):
super(NodeAffiliations, self).__init__(host, 'affiliations', use_profile=False, help=_(u'set or retrieve node affiliations'))
class Node(base.CommandBase):
subcommands = (NodeInfo, NodeSet)
subcommands = (NodeInfo, NodeSet, NodeAffiliations)
def __init__(self, host):
super(Node, self).__init__(host, 'node', use_profile=False, help=_('node handling'))
@ -149,8 +185,37 @@ class Get(base.CommandBase):
errback=self.psItemGetEb)
class Affiliations(base.CommandBase):
def __init__(self, host):
base.CommandBase.__init__(self, host, 'affiliations', use_output=C.OUTPUT_DICT, help=_(u'retrieve all affiliations on a service'))
self.need_loop=True
def add_parser_options(self):
self.parser.add_argument("-n", "--node", type=base.unicode_decoder, default=u'', help=_(u"node to request"))
self.parser.add_argument("-s", "--service", type=base.unicode_decoder, default=u'',
help=_(u"JID of the PubSub service (default: request profile own pubsub)"))
def psAffiliationsGetCb(self, affiliations):
self.output(affiliations)
self.host.quit()
def psAffiliationsGetEb(self, failure_):
self.disp(u"can't get node affiliations: {reason}".format(
reason=failure_), error=True)
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
def start(self):
self.host.bridge.psAffiliationsGet(
self.args.service,
self.args.node,
self.profile,
callback=self.psAffiliationsGetCb,
errback=self.psAffiliationsGetEb)
class Pubsub(base.CommandBase):
subcommands = (Get, Node)
subcommands = (Get, Node, Affiliations)
def __init__(self, host):
super(Pubsub, self).__init__(host, 'pubsub', use_profile=False, help=_('PubSub nodes/items management'))