2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 17:43:14 +00:00

Add definitions for standard messages to pass through pulig api

This commit is contained in:
Jarrod Johnson 2013-11-02 14:52:32 -04:00
parent ec58c47bff
commit bb8c65fc34
2 changed files with 34 additions and 0 deletions

0
confluent/__init__.py Normal file
View File

34
confluent/messages.py Normal file
View File

@ -0,0 +1,34 @@
#Copyright 2013 IBM All rights reserved
# This module implements client/server messages emitted from plugins.
# Things are defined here to 'encourage' developers to coordinate information
# format. This is also how different data formats are supported
import json
class ConfluentMessage(object):
def __init__(self):
raise NotImplementedError("Must be subclassed!")
def json(self):
# This will create the canonical json representation of this message
return json.dumps(self.kvpairs, separators=(',', ':'))
def strip_node(self, node):
self.kvpairs = self.kvpairs[node]
def html(self):
#this is used to facilitate the api explorer feature
pass
class PowerState(ConfluentMessage):
def __init__(self, node, state):
self.kvpairs = {
node: {
'powerstate': state,
}
}